|
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 assertEq(testLenientAndStrict('delete Object();', |
|
29 returns(true), |
|
30 returns(true)), |
|
31 true); |
|
32 |
|
33 /* Functions should inherit the surrounding code's strictness. */ |
|
34 assertEq(testLenientAndStrict('function f() { delete x; }', |
|
35 parsesSuccessfully, |
|
36 parseRaisesException(SyntaxError)), |
|
37 true); |
|
38 |
|
39 /* Local directives override the surrounding code's strictness. */ |
|
40 assertEq(testLenientAndStrict('function f() { "use strict"; delete x; }', |
|
41 parseRaisesException(SyntaxError), |
|
42 parseRaisesException(SyntaxError)), |
|
43 true); |
|
44 |
|
45 reportCompare(true, true); |