summaryrefslogtreecommitdiff
path: root/Libraries/LibJS/Tests/labels.js
blob: 4388cac823e55789d5ae5e6a2cf55d6a5ad8b62d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
load("test-common.js");

try {
    test: {
        let o = 1;
        assert(o === 1);
        break test;
        assertNotReached();
    }

    outer: {
        {
            break outer;
        }
        assertNotReached();
    }

    let counter = 0;
    outer:
    for (a of [1, 2, 3]) {
        for (b of [4, 5, 6]) {
            if (a === 2 && b === 5)
                break outer;
            counter++;
        }
    }
    assert(counter === 4);

    let counter = 0;
    outer:
    for (a of [1, 2, 3]) {
        for (b of [4, 5, 6]) {
            if (b === 6)
                continue outer;
            counter++;
        }
    }
    assert(counter === 6);

    console.log("PASS");
} catch (e) {
    console.log("FAIL: " + e);
}