michael@0: /* michael@0: * Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/licenses/publicdomain/ michael@0: */ michael@0: michael@0: var BadSyntaxStrings = [ michael@0: "function foo1() { \"use strict\"; try {} catch (eval) {} }", michael@0: "function foo2() { \"use strict\"; let eval = 9; foo(); }", michael@0: "function foo3() { \"use strict\"; for (let eval = 3;;) { foo(); }}", michael@0: "function foo4() { \"use strict\"; for (let eval in {a:1}) { foo(); }}", michael@0: "function foo5() { \"use strict\"; for (let eval of [1, 2, 3]) { foo(); }}", michael@0: "function foo6() { \"use strict\"; var eval = 12; }", michael@0: "function foo7() { \"use strict\"; for (var eval = 3;;) { foo(); }}", michael@0: "function foo8() { \"use strict\"; for (var eval in {a:1}) { foo(); }}", michael@0: "function foo9() { \"use strict\"; for (var eval of [1, 2, 3]) { foo(); }}", michael@0: "function foo10() { \"use strict\"; const eval = 12; }", michael@0: "function foo11() { \"use strict\"; for (const eval = 3;;) { foo(); }}", michael@0: "function foo12() { \"use strict\"; return [eval for (eval of [1, 2, 3])]; }", michael@0: "function foo13() { \"use strict\"; return [eval for (eval in {a:3})]; }", michael@0: "function foo14() { \"use strict\"; return (eval for (eval of [1, 2, 3])); }", michael@0: "function foo15() { \"use strict\"; return (eval for (eval in {a:3})); }" michael@0: ]; michael@0: michael@0: function testString(s, i) { michael@0: var gotSyntaxError = -1; michael@0: try { michael@0: eval(s); michael@0: } catch(err) { michael@0: if (err instanceof SyntaxError) michael@0: gotSyntaxError = i; michael@0: } michael@0: michael@0: assertEq(gotSyntaxError, i); michael@0: } michael@0: michael@0: for (var i = 0; i < BadSyntaxStrings.length; i++) michael@0: testString(BadSyntaxStrings[i], i); michael@0: michael@0: reportCompare(true, true);