michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: 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: /* Direct calls to eval should inherit the strictness of the calling code. */ michael@0: assertEq(testLenientAndStrict("eval('010')", michael@0: completesNormally, michael@0: raisesException(SyntaxError)), michael@0: true); michael@0: michael@0: /* michael@0: * Directives in the eval code itself should always override a direct michael@0: * caller's strictness. michael@0: */ michael@0: assertEq(testLenientAndStrict("eval('\"use strict\"; 010')", michael@0: raisesException(SyntaxError), michael@0: raisesException(SyntaxError)), michael@0: true); michael@0: michael@0: /* Code passed to indirect calls to eval should never be strict. */ michael@0: assertEq(testLenientAndStrict("var evil=eval; evil('010')", michael@0: completesNormally, michael@0: completesNormally), michael@0: true); michael@0: michael@0: /* michael@0: * Code passed to the Function constructor never inherits the caller's michael@0: * strictness. michael@0: */ michael@0: assertEq(completesNormally("Function('010')"), michael@0: true); michael@0: assertEq(raisesException(SyntaxError)("Function('\"use strict\"; 010')"), michael@0: true); michael@0: michael@0: /* michael@0: * If 'eval' causes a frame's primitive |this| to become wrapped, the frame should see the same michael@0: * wrapper object as the eval code. michael@0: */ michael@0: var call_this, eval_this; michael@0: function f(code) { michael@0: /* michael@0: * At this point, a primitive |this| has not yet been wrapped. A michael@0: * reference to |this| from the eval call should wrap it, and the wrapper michael@0: * should be stored where the call frame can see it. michael@0: */ michael@0: eval(code); michael@0: call_this = this; michael@0: } michael@0: f.call(true, 'eval_this = this'); michael@0: assertEq(call_this, eval_this); michael@0: michael@0: reportCompare(true, true);