]>
Commit | Line | Data |
---|---|---|
ed1e77d3 A |
1 | (function() { |
2 | // Remove a yet-to-be-visited indexed property during iteration. | |
3 | var foo = function() { | |
4 | var a = [1, 2, 3, 4, 5]; | |
5 | var result = ""; | |
6 | for (var p in a) { | |
7 | if (p == 2) | |
8 | delete a[3]; | |
9 | result += a[p]; | |
10 | } | |
11 | return result; | |
12 | }; | |
13 | noInline(foo); | |
14 | for (var i = 0; i < 10000; ++i) { | |
15 | if (foo() !== "1235") | |
16 | throw new Error("bad result"); | |
17 | } | |
18 | foo(null); | |
19 | })(); | |
20 | (function() { | |
21 | // Remove a yet-to-be-visited non-indexed property during iteration. | |
22 | var foo = function() { | |
23 | var o = {}; | |
24 | o.x = "x"; | |
25 | o.y = "y"; | |
26 | o.z = "z"; | |
27 | var result = ""; | |
28 | for (var p in o) { | |
29 | if (p == "x") { | |
30 | delete o.y; | |
31 | o.a = "a"; | |
32 | } | |
33 | result += o[p]; | |
34 | } | |
35 | return result; | |
36 | }; | |
37 | noInline(foo); | |
38 | for (var i = 0; i < 10000; ++i) { | |
39 | if (foo() !== "xz") | |
40 | throw new Error("bad result"); | |
41 | } | |
42 | })(); | |
43 | (function() { | |
44 | // Remove then re-add a property during iteration. | |
45 | var foo = function() { | |
46 | var A = function() {}; | |
47 | A.prototype.x = "A.x"; | |
48 | A.prototype.y = "A.y"; | |
49 | var o = new A(); | |
50 | o.z = "o.z"; | |
51 | o.y = "o.y"; | |
52 | o.x = "o.x"; | |
53 | var result = ""; | |
54 | for (var p in o) { | |
55 | if (p == "z") | |
56 | delete o.x; | |
57 | if (p == "y") | |
58 | o.x = "o.x"; | |
59 | result += o[p]; | |
60 | } | |
61 | return result; | |
62 | }; | |
63 | noInline(foo); | |
64 | for (var i = 0; i < 10000; ++i) { | |
65 | if (foo() !== "o.zo.yo.x") | |
66 | throw new Error("bad result"); | |
67 | } | |
68 | foo(null); | |
69 | })(); |