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 code; michael@0: michael@0: code = michael@0: "eval('var x = 2; typeof x');"; michael@0: assertEq(testLenientAndStrict(code, returns("number"), returns("number")), michael@0: true); michael@0: michael@0: code = michael@0: "eval('\"use strict\"; var x = 2; typeof x');"; michael@0: assertEq(testLenientAndStrict(code, returns("number"), returns("number")), michael@0: true); michael@0: michael@0: code = michael@0: "eval('var x = 2;'); " + michael@0: "typeof x"; michael@0: assertEq(testLenientAndStrict(code, returns("number"), returns("undefined")), michael@0: true); michael@0: michael@0: code = michael@0: "eval('\"use strict\"; var x = 2;'); " + michael@0: "typeof x"; michael@0: assertEq(testLenientAndStrict(code, returns("undefined"), returns("undefined")), michael@0: true); michael@0: michael@0: code = michael@0: "eval('\"use strict\"; var x = 2; typeof x'); " + michael@0: "typeof x"; michael@0: assertEq(testLenientAndStrict(code, returns("undefined"), returns("undefined")), michael@0: true); michael@0: michael@0: code = michael@0: "function test() " + michael@0: "{ " + michael@0: " eval('var x = 2;'); " + michael@0: " return typeof x; " + michael@0: "} " + michael@0: "test();"; michael@0: assertEq(testLenientAndStrict(code, returns("number"), returns("undefined")), michael@0: true); michael@0: michael@0: code = michael@0: "function test() " + michael@0: "{ " + michael@0: " 'use strict'; " + michael@0: " eval('var x = 2;'); " + michael@0: " return typeof x; " + michael@0: "} " + michael@0: "test();"; michael@0: assertEq(testLenientAndStrict(code, returns("undefined"), returns("undefined")), michael@0: true); michael@0: michael@0: code = michael@0: "function test() " + michael@0: "{ " + michael@0: " eval('\"use strict\"; var x = 2;'); " + michael@0: " return typeof x; " + michael@0: "} " + michael@0: "test();"; michael@0: assertEq(testLenientAndStrict(code, returns("undefined"), returns("undefined")), michael@0: true); michael@0: michael@0: reportCompare(true, true);