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 |
| 188 // Compound assignment to eval or arguments |
| 189 CheckStrictMode("function strict() { eval *= undefined; }", SyntaxError) |
| 190 CheckStrictMode("function strict() { arguments /= undefined; }", SyntaxError) |
| 191 CheckStrictMode("function strict() { print(eval %= undefined); }", SyntaxError) |
| 192 CheckStrictMode("function strict() { print(arguments %= undefined); }", SyntaxEr
ror) |
| 193 CheckStrictMode("function strict() { var x = eval += undefined; }", SyntaxError) |
| 194 CheckStrictMode("function strict() { var x = arguments -= undefined; }", SyntaxE
rror) |
| 195 CheckStrictMode("function strict() { eval <<= undefined; }", SyntaxError) |
| 196 CheckStrictMode("function strict() { arguments >>= undefined; }", SyntaxError) |
| 197 CheckStrictMode("function strict() { print(eval >>>= undefined); }", SyntaxError
) |
| 198 CheckStrictMode("function strict() { print(arguments &= undefined); }", SyntaxEr
ror) |
| 199 CheckStrictMode("function strict() { var x = eval ^= undefined; }", SyntaxError) |
| 200 CheckStrictMode("function strict() { var x = arguments |= undefined; }", SyntaxE
rror) |
| 201 |
| 202 // Postfix increment with eval or arguments |
| 203 CheckStrictMode("function strict() { eval++; }", SyntaxError) |
| 204 CheckStrictMode("function strict() { arguments++; }", SyntaxError) |
| 205 CheckStrictMode("function strict() { print(eval++); }", SyntaxError) |
| 206 CheckStrictMode("function strict() { print(arguments++); }", SyntaxError) |
| 207 CheckStrictMode("function strict() { var x = eval++; }", SyntaxError) |
| 208 CheckStrictMode("function strict() { var x = arguments++; }", SyntaxError) |
| 209 |
| 210 // Postfix decrement with eval or arguments |
| 211 CheckStrictMode("function strict() { eval--; }", SyntaxError) |
| 212 CheckStrictMode("function strict() { arguments--; }", SyntaxError) |
| 213 CheckStrictMode("function strict() { print(eval--); }", SyntaxError) |
| 214 CheckStrictMode("function strict() { print(arguments--); }", SyntaxError) |
| 215 CheckStrictMode("function strict() { var x = eval--; }", SyntaxError) |
| 216 CheckStrictMode("function strict() { var x = arguments--; }", SyntaxError) |
| 217 |
| 218 // Prefix increment with eval or arguments |
| 219 CheckStrictMode("function strict() { ++eval; }", SyntaxError) |
| 220 CheckStrictMode("function strict() { ++arguments; }", SyntaxError) |
| 221 CheckStrictMode("function strict() { print(++eval); }", SyntaxError) |
| 222 CheckStrictMode("function strict() { print(++arguments); }", SyntaxError) |
| 223 CheckStrictMode("function strict() { var x = ++eval; }", SyntaxError) |
| 224 CheckStrictMode("function strict() { var x = ++arguments; }", SyntaxError) |
| 225 |
| 226 // Prefix decrement with eval or arguments |
| 227 CheckStrictMode("function strict() { --eval; }", SyntaxError) |
| 228 CheckStrictMode("function strict() { --arguments; }", SyntaxError) |
| 229 CheckStrictMode("function strict() { print(--eval); }", SyntaxError) |
| 230 CheckStrictMode("function strict() { print(--arguments); }", SyntaxError) |
| 231 CheckStrictMode("function strict() { var x = --eval; }", SyntaxError) |
| 232 CheckStrictMode("function strict() { var x = --arguments; }", SyntaxError) |
| 233 |
| 234 // Prefix unary operators other than delete, ++, -- are valid in strict mode |
| 235 function StrictModeUnaryOperators() { |
| 236 "use strict"; |
| 237 var x = [void eval, typeof eval, +eval, -eval, ~eval, !eval]; |
| 238 var y = [void arguments, typeof arguments, |
| 239 +arguments, -arguments, ~arguments, !arguments]; |
| 240 } |
OLD | NEW |