js/src/tests/ecma_5/strict/11.4.1.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 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2
michael@0 3 /*
michael@0 4 * Any copyright is dedicated to the Public Domain.
michael@0 5 * http://creativecommons.org/licenses/publicdomain/
michael@0 6 */
michael@0 7
michael@0 8 /* Deleting an identifier is a syntax error in strict mode code only. */
michael@0 9 assertEq(testLenientAndStrict('delete x;',
michael@0 10 parsesSuccessfully,
michael@0 11 parseRaisesException(SyntaxError)),
michael@0 12 true);
michael@0 13
michael@0 14 /*
michael@0 15 * A reference expression surrounded by parens is itself a reference
michael@0 16 * expression.
michael@0 17 */
michael@0 18 assertEq(testLenientAndStrict('delete (x);',
michael@0 19 parsesSuccessfully,
michael@0 20 parseRaisesException(SyntaxError)),
michael@0 21 true);
michael@0 22
michael@0 23 /* Deleting other sorts of expressions are not syntax errors in either mode. */
michael@0 24 assertEq(testLenientAndStrict('delete x.y;',
michael@0 25 parsesSuccessfully,
michael@0 26 parsesSuccessfully),
michael@0 27 true);
michael@0 28 assertEq(testLenientAndStrict('delete Object();',
michael@0 29 returns(true),
michael@0 30 returns(true)),
michael@0 31 true);
michael@0 32
michael@0 33 /* Functions should inherit the surrounding code's strictness. */
michael@0 34 assertEq(testLenientAndStrict('function f() { delete x; }',
michael@0 35 parsesSuccessfully,
michael@0 36 parseRaisesException(SyntaxError)),
michael@0 37 true);
michael@0 38
michael@0 39 /* Local directives override the surrounding code's strictness. */
michael@0 40 assertEq(testLenientAndStrict('function f() { "use strict"; delete x; }',
michael@0 41 parseRaisesException(SyntaxError),
michael@0 42 parseRaisesException(SyntaxError)),
michael@0 43 true);
michael@0 44
michael@0 45 reportCompare(true, true);

mercurial