OLD | NEW |
---|---|
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
138 CheckStrictMode("var x = { 3.14 : 1, '3.14' : 2 };", SyntaxError) | 138 CheckStrictMode("var x = { 3.14 : 1, '3.14' : 2 };", SyntaxError) |
139 CheckStrictMode("var x = { 123: 1, 123.00000000000000000000000000000000000000000 000000000000000000000000001 : 2 }", SyntaxError) | 139 CheckStrictMode("var x = { 123: 1, 123.00000000000000000000000000000000000000000 000000000000000000000000001 : 2 }", SyntaxError) |
140 | 140 |
141 // Non-conflicting data properties. | 141 // Non-conflicting data properties. |
142 function StrictModeNonDuplicate() { | 142 function StrictModeNonDuplicate() { |
143 "use strict"; | 143 "use strict"; |
144 var x = { 123 : 1, "0123" : 2 }; | 144 var x = { 123 : 1, "0123" : 2 }; |
145 var x = { 123: 1, '123.0000000000000000000000000000000000000000000000000000000 0000000000001' : 2 } | 145 var x = { 123: 1, '123.0000000000000000000000000000000000000000000000000000000 0000000000001' : 2 } |
146 } | 146 } |
147 | 147 |
148 //CheckStrictMode("", SyntaxError) | |
149 | |
150 // Two getters (non-strict) | 148 // Two getters (non-strict) |
151 assertThrows("var x = { get foo() { }, get foo() { } };", SyntaxError) | 149 assertThrows("var x = { get foo() { }, get foo() { } };", SyntaxError) |
152 assertThrows("var x = { get foo(){}, get 'foo'(){}};", SyntaxError) | 150 assertThrows("var x = { get foo(){}, get 'foo'(){}};", SyntaxError) |
153 assertThrows("var x = { get 12(){}, get '12'(){}};", SyntaxError) | 151 assertThrows("var x = { get 12(){}, get '12'(){}};", SyntaxError) |
154 | 152 |
155 // Two setters (non-strict) | 153 // Two setters (non-strict) |
156 assertThrows("var x = { set foo(v) { }, set foo(v) { } };", SyntaxError) | 154 assertThrows("var x = { set foo(v) { }, set foo(v) { } };", SyntaxError) |
157 assertThrows("var x = { set foo(v) { }, set 'foo'(v) { } };", SyntaxError) | 155 assertThrows("var x = { set foo(v) { }, set 'foo'(v) { } };", SyntaxError) |
158 assertThrows("var x = { set 13(v) { }, set '13'(v) { } };", SyntaxError) | 156 assertThrows("var x = { set 13(v) { }, set '13'(v) { } };", SyntaxError) |
159 | 157 |
(...skipping 11 matching lines...) Expand all Loading... | |
171 assertThrows("var x = { '12': 1, set '12'(v){}};", SyntaxError); | 169 assertThrows("var x = { '12': 1, set '12'(v){}};", SyntaxError); |
172 assertThrows("var x = { '12': 1, set 12(v){}};", SyntaxError); | 170 assertThrows("var x = { '12': 1, set 12(v){}};", SyntaxError); |
173 | 171 |
174 // Getter and data (non-strict) | 172 // Getter and data (non-strict) |
175 assertThrows("var x = { foo: 'data', get foo() { } };", SyntaxError) | 173 assertThrows("var x = { foo: 'data', get foo() { } };", SyntaxError) |
176 assertThrows("var x = { get foo() { }, foo: 'data' };", SyntaxError) | 174 assertThrows("var x = { get foo() { }, foo: 'data' };", SyntaxError) |
177 assertThrows("var x = { 'foo': 'data', get foo() { } };", SyntaxError) | 175 assertThrows("var x = { 'foo': 'data', get foo() { } };", SyntaxError) |
178 assertThrows("var x = { get 'foo'() { }, 'foo': 'data' };", SyntaxError) | 176 assertThrows("var x = { get 'foo'() { }, 'foo': 'data' };", SyntaxError) |
179 assertThrows("var x = { '12': 1, get '12'(){}};", SyntaxError); | 177 assertThrows("var x = { '12': 1, get '12'(){}};", SyntaxError); |
180 assertThrows("var x = { '12': 1, get 12(){}};", SyntaxError); | 178 assertThrows("var x = { '12': 1, get 12(){}};", SyntaxError); |
179 | |
180 // Assignment to eval or arguments | |
181 CheckStrictMode("function strict() { eval = undefined; }", SyntaxError) | |
182 CheckStrictMode("function strict() { arguments = undefined; }", SyntaxError) | |
183 CheckStrictMode("function strict() { print(eval = undefined); }", SyntaxError) | |
184 CheckStrictMode("function strict() { print(arguments = undefined); }", SyntaxErr or) | |
185 CheckStrictMode("function strict() { var x = eval = undefined; }", SyntaxError) | |
186 CheckStrictMode("function strict() { var x = arguments = undefined; }", SyntaxEr ror) | |
187 | |
Lasse Reichstein
2011/01/26 08:03:59
Try a compound assignment operator as well, e.g.,
Martin Maly
2011/01/26 19:19:33
Done.
| |
188 // Postfix increment with eval or arguments | |
189 CheckStrictMode("function strict() { eval++; }", SyntaxError) | |
190 CheckStrictMode("function strict() { arguments++; }", SyntaxError) | |
191 CheckStrictMode("function strict() { print(eval++); }", SyntaxError) | |
192 CheckStrictMode("function strict() { print(arguments++); }", SyntaxError) | |
193 CheckStrictMode("function strict() { var x = eval++; }", SyntaxError) | |
194 CheckStrictMode("function strict() { var x = arguments++; }", SyntaxError) | |
195 | |
196 // Postfix decrement with eval or arguments | |
197 CheckStrictMode("function strict() { eval--; }", SyntaxError) | |
198 CheckStrictMode("function strict() { arguments--; }", SyntaxError) | |
199 CheckStrictMode("function strict() { print(eval--); }", SyntaxError) | |
200 CheckStrictMode("function strict() { print(arguments--); }", SyntaxError) | |
201 CheckStrictMode("function strict() { var x = eval--; }", SyntaxError) | |
202 CheckStrictMode("function strict() { var x = arguments--; }", SyntaxError) | |
203 | |
204 // Prefix increment with eval or arguments | |
205 CheckStrictMode("function strict() { ++eval; }", SyntaxError) | |
206 CheckStrictMode("function strict() { ++arguments; }", SyntaxError) | |
207 CheckStrictMode("function strict() { print(++eval); }", SyntaxError) | |
208 CheckStrictMode("function strict() { print(++arguments); }", SyntaxError) | |
209 CheckStrictMode("function strict() { var x = ++eval; }", SyntaxError) | |
210 CheckStrictMode("function strict() { var x = ++arguments; }", SyntaxError) | |
211 | |
212 // Prefix decrement with eval or arguments | |
213 CheckStrictMode("function strict() { --eval; }", SyntaxError) | |
214 CheckStrictMode("function strict() { --arguments; }", SyntaxError) | |
215 CheckStrictMode("function strict() { print(--eval); }", SyntaxError) | |
216 CheckStrictMode("function strict() { print(--arguments); }", SyntaxError) | |
217 CheckStrictMode("function strict() { var x = --eval; }", SyntaxError) | |
218 CheckStrictMode("function strict() { var x = --arguments; }", SyntaxError) | |
Lasse Reichstein
2011/01/26 08:03:59
Check that not-lvalue-operand operators doesn't th
Martin Maly
2011/01/26 19:19:33
Done.
| |
219 | |
OLD | NEW |