js/src/tests/ecma_5/strict/rebind-eval-should-fail-in-strict-mode.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /*
michael@0 2 * Any copyright is dedicated to the Public Domain.
michael@0 3 * http://creativecommons.org/licenses/publicdomain/
michael@0 4 */
michael@0 5
michael@0 6 var BadSyntaxStrings = [
michael@0 7 "function foo1() { \"use strict\"; try {} catch (eval) {} }",
michael@0 8 "function foo2() { \"use strict\"; let eval = 9; foo(); }",
michael@0 9 "function foo3() { \"use strict\"; for (let eval = 3;;) { foo(); }}",
michael@0 10 "function foo4() { \"use strict\"; for (let eval in {a:1}) { foo(); }}",
michael@0 11 "function foo5() { \"use strict\"; for (let eval of [1, 2, 3]) { foo(); }}",
michael@0 12 "function foo6() { \"use strict\"; var eval = 12; }",
michael@0 13 "function foo7() { \"use strict\"; for (var eval = 3;;) { foo(); }}",
michael@0 14 "function foo8() { \"use strict\"; for (var eval in {a:1}) { foo(); }}",
michael@0 15 "function foo9() { \"use strict\"; for (var eval of [1, 2, 3]) { foo(); }}",
michael@0 16 "function foo10() { \"use strict\"; const eval = 12; }",
michael@0 17 "function foo11() { \"use strict\"; for (const eval = 3;;) { foo(); }}",
michael@0 18 "function foo12() { \"use strict\"; return [eval for (eval of [1, 2, 3])]; }",
michael@0 19 "function foo13() { \"use strict\"; return [eval for (eval in {a:3})]; }",
michael@0 20 "function foo14() { \"use strict\"; return (eval for (eval of [1, 2, 3])); }",
michael@0 21 "function foo15() { \"use strict\"; return (eval for (eval in {a:3})); }"
michael@0 22 ];
michael@0 23
michael@0 24 function testString(s, i) {
michael@0 25 var gotSyntaxError = -1;
michael@0 26 try {
michael@0 27 eval(s);
michael@0 28 } catch(err) {
michael@0 29 if (err instanceof SyntaxError)
michael@0 30 gotSyntaxError = i;
michael@0 31 }
michael@0 32
michael@0 33 assertEq(gotSyntaxError, i);
michael@0 34 }
michael@0 35
michael@0 36 for (var i = 0; i < BadSyntaxStrings.length; i++)
michael@0 37 testString(BadSyntaxStrings[i], i);
michael@0 38
michael@0 39 reportCompare(true, true);

mercurial