OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. | 2 // Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. |
3 // | 3 // |
4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
5 // modification, are permitted provided that the following conditions | 5 // modification, are permitted provided that the following conditions |
6 // are met: | 6 // are met: |
7 // 1. Redistributions of source code must retain the above copyright | 7 // 1. Redistributions of source code must retain the above copyright |
8 // notice, this list of conditions and the following disclaimer. | 8 // notice, this list of conditions and the following disclaimer. |
9 // 2. Redistributions in binary form must reproduce the above copyright | 9 // 2. Redistributions in binary form must reproduce the above copyright |
10 // notice, this list of conditions and the following disclaimer in the | 10 // notice, this list of conditions and the following disclaimer in the |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 invalid("with a.b { }"); | 212 invalid("with a.b { }"); |
213 valid ("while (a() - new b) ;"); | 213 valid ("while (a() - new b) ;"); |
214 invalid("while a {}"); | 214 invalid("while a {}"); |
215 valid ("do ; while(0) i++"); // Is this REALLY valid? (Firefox also accepts thi
s) | 215 valid ("do ; while(0) i++"); // Is this REALLY valid? (Firefox also accepts thi
s) |
216 valid ("do if (a) x; else y; while(z)"); | 216 valid ("do if (a) x; else y; while(z)"); |
217 invalid("do g; while 4"); | 217 invalid("do g; while 4"); |
218 invalid("do g; while ((4)"); | 218 invalid("do g; while ((4)"); |
219 valid ("{ { do do do ; while(0) while(0) while(0) } }"); | 219 valid ("{ { do do do ; while(0) while(0) while(0) } }"); |
220 valid ("do while (0) if (a) {} else y; while(0)"); | 220 valid ("do while (0) if (a) {} else y; while(0)"); |
221 valid ("if (a) while (b) if (c) with(d) {} else e; else f"); | 221 valid ("if (a) while (b) if (c) with(d) {} else e; else f"); |
222 invalid("break ; break your_limits ; continue ; continue living ; debugger"); | |
223 invalid("debugger X"); | 222 invalid("debugger X"); |
224 invalid("break 0.2"); | 223 invalid("break 0.2"); |
225 invalid("continue a++"); | 224 invalid("continue a++"); |
226 invalid("continue (my_friend)"); | 225 invalid("continue (my_friend)"); |
227 valid ("while (1) break"); | 226 valid ("while (1) break"); |
228 valid ("do if (a) with (b) continue; else debugger; while (false)"); | 227 valid ("do if (a) with (b) continue; else debugger; while (false)"); |
229 invalid("do if (a) while (false) else debugger"); | 228 invalid("do if (a) while (false) else debugger"); |
230 invalid("while if (a) ;"); | 229 invalid("while if (a) ;"); |
231 valid ("if (a) function f() {} else function g() {}"); | 230 valid ("if (a) function f() {} else function g() {}"); |
232 invalid("if (a()) while(0) function f() {} else function g() {}"); | 231 invalid("if (a()) while(0) function f() {} else function g() {}"); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 invalid("for (var a, b in b) break"); | 312 invalid("for (var a, b in b) break"); |
314 invalid("for (var a = -6, b in b) break"); | 313 invalid("for (var a = -6, b in b) break"); |
315 invalid("for (var a, b = 8 in b) break"); | 314 invalid("for (var a, b = 8 in b) break"); |
316 valid ("for (var a = (b in c) in d) break"); | 315 valid ("for (var a = (b in c) in d) break"); |
317 invalid("for (var a = (b in c in d) break"); | 316 invalid("for (var a = (b in c in d) break"); |
318 invalid("for (var (a) in b) { }"); | 317 invalid("for (var (a) in b) { }"); |
319 valid ("for (var a = 7, b = c < d >= d ; f()[6]++ ; --i()[1]++ ) {}"); | 318 valid ("for (var a = 7, b = c < d >= d ; f()[6]++ ; --i()[1]++ ) {}"); |
320 | 319 |
321 debug ("try statement"); | 320 debug ("try statement"); |
322 | 321 |
323 invalid("try { break } catch(e) {}"); | |
324 valid ("try {} finally { c++ }"); | 322 valid ("try {} finally { c++ }"); |
325 valid ("try { with (x) { } } catch(e) {} finally { if (a) ; }"); | 323 valid ("try { with (x) { } } catch(e) {} finally { if (a) ; }"); |
326 invalid("try {}"); | 324 invalid("try {}"); |
327 invalid("catch(e) {}"); | 325 invalid("catch(e) {}"); |
328 invalid("finally {}"); | 326 invalid("finally {}"); |
329 invalid("try a; catch(e) {}"); | 327 invalid("try a; catch(e) {}"); |
330 invalid("try {} catch(e) a()"); | 328 invalid("try {} catch(e) a()"); |
331 invalid("try {} finally a()"); | 329 invalid("try {} finally a()"); |
332 invalid("try {} catch(e)"); | 330 invalid("try {} catch(e)"); |
333 invalid("try {} finally"); | 331 invalid("try {} finally"); |
(...skipping 22 matching lines...) Expand all Loading... |
356 invalid("switch (g) { case 1: a: default: }"); | 354 invalid("switch (g) { case 1: a: default: }"); |
357 invalid("switch g { case 1: l() }"); | 355 invalid("switch g { case 1: l() }"); |
358 invalid("switch (g) { case 1:"); | 356 invalid("switch (g) { case 1:"); |
359 valid ("switch (l) { case a = b ? c : d : }"); | 357 valid ("switch (l) { case a = b ? c : d : }"); |
360 valid ("switch (sw) { case a ? b - 7[1] ? [c,,] : d = 6 : { } : }"); | 358 valid ("switch (sw) { case a ? b - 7[1] ? [c,,] : d = 6 : { } : }"); |
361 invalid("switch (l) { case b ? c : }"); | 359 invalid("switch (l) { case b ? c : }"); |
362 valid ("switch (l) { case 1: a: with(g) switch (g) { case 2: default: } default
: }"); | 360 valid ("switch (l) { case 1: a: with(g) switch (g) { case 2: default: } default
: }"); |
363 invalid("switch (4 - ) { }"); | 361 invalid("switch (4 - ) { }"); |
364 invalid("switch (l) { default case: 5; }"); | 362 invalid("switch (l) { default case: 5; }"); |
365 | 363 |
366 invalid("L: L: ;"); | |
367 invalid("L: L1: L: ;"); | |
368 invalid("L: L1: L2: L3: L4: L: ;"); | |
369 | |
370 invalid("for(var a,b 'this shouldn\'t be allowed' false ; ) ;"); | 364 invalid("for(var a,b 'this shouldn\'t be allowed' false ; ) ;"); |
371 invalid("for(var a,b '"); | 365 invalid("for(var a,b '"); |
372 | 366 |
373 valid("function __proto__(){}") | 367 valid("function __proto__(){}") |
374 valid("(function __proto__(){})") | 368 valid("(function __proto__(){})") |
375 valid("'use strict'; function __proto__(){}") | 369 valid("'use strict'; function __proto__(){}") |
376 valid("'use strict'; (function __proto__(){})") | 370 valid("'use strict'; (function __proto__(){})") |
377 | 371 |
378 valid("if (0) $foo; ") | 372 valid("if (0) $foo; ") |
379 valid("if (0) _foo; ") | 373 valid("if (0) _foo; ") |
(...skipping 14 matching lines...) Expand all Loading... |
394 | 388 |
395 try { eval("a.b.c = {};"); } catch(e1) { e=e1; shouldBe("e.line", "1") } | 389 try { eval("a.b.c = {};"); } catch(e1) { e=e1; shouldBe("e.line", "1") } |
396 foo = 'FAIL'; | 390 foo = 'FAIL'; |
397 bar = 'PASS'; | 391 bar = 'PASS'; |
398 try { | 392 try { |
399 eval("foo = 'PASS'; a.b.c = {}; bar = 'FAIL';"); | 393 eval("foo = 'PASS'; a.b.c = {}; bar = 'FAIL';"); |
400 } catch(e) { | 394 } catch(e) { |
401 shouldBe("foo", "'PASS'"); | 395 shouldBe("foo", "'PASS'"); |
402 shouldBe("bar", "'PASS'"); | 396 shouldBe("bar", "'PASS'"); |
403 } | 397 } |
OLD | NEW |