js/src/jit-test/tests/arrow-functions/syntax-errors.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 // Check that we correctly throw SyntaxErrors for various syntactic near-misses.
michael@0 2
michael@0 3 load(libdir + "asserts.js");
michael@0 4
michael@0 5 var mistakes = [
michael@0 6 "((a)) => expr",
michael@0 7 "a + b => a",
michael@0 8 "'' + a => a",
michael@0 9 "...x",
michael@0 10 "[x] => x",
michael@0 11 "([x] => x)",
michael@0 12 "{p: p} => p",
michael@0 13 "({p: p} => p)",
michael@0 14 "{p} => p",
michael@0 15 "(...x => expr)",
michael@0 16 "1 || a => a",
michael@0 17 "'use strict' => {}",
michael@0 18 "package => {'use strict';}", // tricky: FutureReservedWord in strict mode code only
michael@0 19 "'use strict'; arguments => 0", // names banned in strict mode code
michael@0 20 "'use strict'; eval => 0",
michael@0 21 "a => {'use strict'; with (a) return x; }",
michael@0 22 "a => yield a",
michael@0 23 "a => { yield a; }",
michael@0 24 "a => { { let x; yield a; } }",
michael@0 25 "(a = yield 0) => a",
michael@0 26 "for (;;) a => { break; };",
michael@0 27 "for (;;) a => { continue; };",
michael@0 28 "...rest) =>",
michael@0 29 "2 + ...rest) =>"
michael@0 30 ];
michael@0 31
michael@0 32 for (var s of mistakes)
michael@0 33 assertThrowsInstanceOf(function () { Function(s); }, SyntaxError);
michael@0 34
michael@0 35 // Check that the tricky case is not an error in non-strict-mode code.
michael@0 36 var f = package => 0;
michael@0 37 assertEq(f(1), 0);
michael@0 38

mercurial