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