blob: 2e58cdf636f04d607f02e0ac4ee92b71538b9dd5 (
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
|
Testing object iteration behavior.
1. Testing that deleting properties during iteration is safe.
-- Expect stdout --
a
w
z
-- End --
-- Testcase --
{%
o1 = { a: 1, b: 2, c: 3 };
for (k in o1) {
delete o1.a;
delete o1.b;
delete o1.c;
print(k, "\n");
}
o2 = { w: 1, x: 2, y: 3, z: 4 };
for (k in o2) {
delete o2.x;
delete o2.y;
print(k, "\n");
}
%}
-- End --
2. Test that reordering object properties during iteration is safe.
-- Expect stdout --
c
b
c
-- End --
-- Testcase --
{%
o = { c: 1, b: 2, a: 3 };
for (k in o) {
sort(o);
print(k, "\n");
}
%}
-- End --
|