Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | // Labeled break tests. |
michael@0 | 2 | function f1() { |
michael@0 | 3 | foo: |
michael@0 | 4 | if ([1]) { |
michael@0 | 5 | bar: |
michael@0 | 6 | for (var i=0; i<100; i++) { |
michael@0 | 7 | if (i > 60) |
michael@0 | 8 | break foo; |
michael@0 | 9 | } |
michael@0 | 10 | assertEq(0, 1); |
michael@0 | 11 | } |
michael@0 | 12 | assertEq(i, 61); |
michael@0 | 13 | return true; |
michael@0 | 14 | } |
michael@0 | 15 | assertEq(f1(), true); |
michael@0 | 16 | |
michael@0 | 17 | // Label with no breaks. |
michael@0 | 18 | function f2() { |
michael@0 | 19 | foo: |
michael@0 | 20 | if ([1]) { |
michael@0 | 21 | for (var i=0; i<100; i++) { |
michael@0 | 22 | } |
michael@0 | 23 | } |
michael@0 | 24 | assertEq(i, 100); |
michael@0 | 25 | return true; |
michael@0 | 26 | } |
michael@0 | 27 | assertEq(f2(), true); |
michael@0 | 28 | |
michael@0 | 29 | // No breaks and early return. |
michael@0 | 30 | function f3() { |
michael@0 | 31 | foo: { |
michael@0 | 32 | if (true) { |
michael@0 | 33 | for (var i=0; i<100; i++) { |
michael@0 | 34 | } |
michael@0 | 35 | } |
michael@0 | 36 | return false; |
michael@0 | 37 | } |
michael@0 | 38 | assertEq(i, 100); |
michael@0 | 39 | return true; |
michael@0 | 40 | } |
michael@0 | 41 | assertEq(f3(), false); |
michael@0 | 42 | |
michael@0 | 43 | // Multiple breaks. |
michael@0 | 44 | function f4() { |
michael@0 | 45 | foo: { |
michael@0 | 46 | if (true) { |
michael@0 | 47 | for (var i=0; i<100; i++) |
michael@0 | 48 | if (i > 70) |
michael@0 | 49 | break foo; |
michael@0 | 50 | if (i > 80) |
michael@0 | 51 | break foo; |
michael@0 | 52 | } |
michael@0 | 53 | break foo; |
michael@0 | 54 | } |
michael@0 | 55 | assertEq(i, 71); |
michael@0 | 56 | return true; |
michael@0 | 57 | } |
michael@0 | 58 | assertEq(f4(), true); |