js/src/tests/ecma_5/strict/11.4.1.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/tests/ecma_5/strict/11.4.1.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,45 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +
     1.6 +/*
     1.7 + * Any copyright is dedicated to the Public Domain.
     1.8 + * http://creativecommons.org/licenses/publicdomain/
     1.9 + */
    1.10 +
    1.11 +/* Deleting an identifier is a syntax error in strict mode code only. */
    1.12 +assertEq(testLenientAndStrict('delete x;',
    1.13 +                              parsesSuccessfully,
    1.14 +                              parseRaisesException(SyntaxError)),
    1.15 +         true);
    1.16 +
    1.17 +/*
    1.18 + * A reference expression surrounded by parens is itself a reference
    1.19 + * expression.
    1.20 + */
    1.21 +assertEq(testLenientAndStrict('delete (x);',
    1.22 +                              parsesSuccessfully,
    1.23 +                              parseRaisesException(SyntaxError)),
    1.24 +         true);
    1.25 +
    1.26 +/* Deleting other sorts of expressions are not syntax errors in either mode. */
    1.27 +assertEq(testLenientAndStrict('delete x.y;',
    1.28 +                              parsesSuccessfully,
    1.29 +                              parsesSuccessfully),
    1.30 +         true);
    1.31 +assertEq(testLenientAndStrict('delete Object();',
    1.32 +                              returns(true),
    1.33 +                              returns(true)),
    1.34 +         true);
    1.35 +
    1.36 +/* Functions should inherit the surrounding code's strictness. */
    1.37 +assertEq(testLenientAndStrict('function f() { delete x; }',
    1.38 +                              parsesSuccessfully,
    1.39 +                              parseRaisesException(SyntaxError)),
    1.40 +         true);
    1.41 +
    1.42 +/* Local directives override the surrounding code's strictness. */
    1.43 +assertEq(testLenientAndStrict('function f() { "use strict"; delete x; }',
    1.44 +                              parseRaisesException(SyntaxError),
    1.45 +                              parseRaisesException(SyntaxError)),
    1.46 +         true);
    1.47 +
    1.48 +reportCompare(true, true);

mercurial