]>
Commit | Line | Data |
---|---|---|
ed1e77d3 A |
1 | function shouldBe(actual, expected) { |
2 | if (actual !== expected) | |
3 | throw new Error('bad value: ' + actual); | |
4 | } | |
5 | ||
6 | // Simple assignment (not FunctionCallBracketNode). | |
7 | ||
8 | shouldBe(function () { | |
9 | var object = { | |
10 | null: 'ok' | |
11 | }; | |
12 | ||
13 | return object[object = null]; | |
14 | }(), 'ok'); | |
15 | ||
16 | shouldBe(function (value) { | |
17 | var object = { }; | |
18 | object.null = 'ok'; | |
19 | ||
20 | return object[object = value]; | |
21 | }(null), 'ok'); | |
22 | ||
23 | shouldBe(function () { | |
24 | var object = { | |
25 | null: 'ok' | |
26 | }; | |
27 | ||
28 | return object['null']; | |
29 | }(), 'ok'); | |
30 | ||
31 | shouldBe(function (value) { | |
32 | var object = { }; | |
33 | object.null = 'ok'; | |
34 | ||
35 | return object['null']; | |
36 | }(null), 'ok'); | |
37 | ||
38 | shouldBe(function () { | |
39 | var object = { | |
40 | null: 'ok' | |
41 | }; | |
42 | ||
43 | function fill() { | |
44 | return object = null; | |
45 | } | |
46 | ||
47 | return object[fill()]; | |
48 | }(), 'ok'); | |
49 | ||
50 | shouldBe(function (value) { | |
51 | var object = { }; | |
52 | object.null = 'ok'; | |
53 | ||
54 | function fill() { | |
55 | return object = value; | |
56 | } | |
57 | ||
58 | return object[fill()]; | |
59 | }(null), 'ok'); | |
60 | ||
61 | // FunctionCallBracketNode. | |
62 | ||
63 | shouldBe(function () { | |
64 | var object = { | |
65 | null: function () { | |
66 | return 'ok'; | |
67 | } | |
68 | }; | |
69 | ||
70 | return object[object = null](); | |
71 | }(), 'ok'); | |
72 | ||
73 | shouldBe(function (value) { | |
74 | var object = { }; | |
75 | object.null = function () { | |
76 | return 'ok'; | |
77 | }; | |
78 | ||
79 | return object[object = value](); | |
80 | }(null), 'ok'); | |
81 | ||
82 | shouldBe(function () { | |
83 | var object = { | |
84 | null: function () { | |
85 | return 'ok'; | |
86 | } | |
87 | }; | |
88 | ||
89 | return object['null'](); | |
90 | }(), 'ok'); | |
91 | ||
92 | shouldBe(function (value) { | |
93 | var object = { }; | |
94 | object.null = function () { | |
95 | return 'ok'; | |
96 | }; | |
97 | ||
98 | return object['null'](); | |
99 | }(null), 'ok'); | |
100 | ||
101 | shouldBe(function () { | |
102 | var object = { | |
103 | null: function () { | |
104 | return 'ok'; | |
105 | } | |
106 | }; | |
107 | ||
108 | function fill() { | |
109 | return object = null; | |
110 | } | |
111 | ||
112 | return object[fill()](); | |
113 | }(), 'ok'); | |
114 | ||
115 | shouldBe(function (value) { | |
116 | var object = { }; | |
117 | object.null = function () { | |
118 | return 'ok'; | |
119 | }; | |
120 | ||
121 | function fill() { | |
122 | return object = value; | |
123 | } | |
124 | ||
125 | return object[fill()](); | |
126 | }(null), 'ok'); |