summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/statements/for-inof-finally.js
blob: e1f0c77e12e48938d103b685931b94b69a954ae9 (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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
var BUGNUMBER = 1332881;
var summary =
  "Leaving for-in and try should handle stack value in correct order";

print(BUGNUMBER + ": " + summary);

var called = 0;
function reset() {
  called = 0;
}
var obj = {
  [Symbol.iterator]() {
    return {
      next() {
        return { value: 10, done: false };
      },
      return() {
        called++;
        return {};
      }
    };
  }
};

var a = (function () {
    for (var x in [0]) {
        try {} finally {
            return 11;
        }
    }
})();
assertEq(a, 11);

reset();
var b = (function () {
    for (var x of obj) {
        try {} finally {
            return 12;
        }
    }
})();
assertEq(called, 1);
assertEq(b, 12);

reset();
var c = (function () {
    for (var x in [0]) {
        for (var y of obj) {
            try {} finally {
                return 13;
            }
        }
    }
})();
assertEq(called, 1);
assertEq(c, 13);

reset();
var d = (function () {
    for (var x in [0]) {
        for (var y of obj) {
            try {} finally {
                for (var z in [0]) {
                    for (var w of obj) {
                        try {} finally {
                            return 14;
                        }
                    }
                }
            }
        }
    }
})();
assertEq(called, 2);
assertEq(d, 14);

if (typeof reportCompare === "function")
  reportCompare(true, true);