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: /* Deleting an identifier is a syntax error in strict mode code only. */ michael@0: assertEq(testLenientAndStrict('delete x;', michael@0: parsesSuccessfully, michael@0: parseRaisesException(SyntaxError)), michael@0: true); michael@0: michael@0: /* michael@0: * A reference expression surrounded by parens is itself a reference michael@0: * expression. michael@0: */ michael@0: assertEq(testLenientAndStrict('delete (x);', michael@0: parsesSuccessfully, michael@0: parseRaisesException(SyntaxError)), michael@0: true); michael@0: michael@0: /* Deleting other sorts of expressions are not syntax errors in either mode. */ michael@0: assertEq(testLenientAndStrict('delete x.y;', michael@0: parsesSuccessfully, michael@0: parsesSuccessfully), michael@0: true); michael@0: assertEq(testLenientAndStrict('delete Object();', michael@0: returns(true), michael@0: returns(true)), michael@0: true); michael@0: michael@0: /* Functions should inherit the surrounding code's strictness. */ michael@0: assertEq(testLenientAndStrict('function f() { delete x; }', michael@0: parsesSuccessfully, michael@0: parseRaisesException(SyntaxError)), michael@0: true); michael@0: michael@0: /* Local directives override the surrounding code's strictness. */ michael@0: assertEq(testLenientAndStrict('function f() { "use strict"; delete x; }', michael@0: parseRaisesException(SyntaxError), michael@0: parseRaisesException(SyntaxError)), michael@0: true); michael@0: michael@0: reportCompare(true, true);