blob: d28afb665c2cc7b56cdd305a9088e48a38ed7b38 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
// Any copyright is dedicated to the Public Domain.
// http://creativecommons.org/licenses/publicdomain/
//-----------------------------------------------------------------------------
var BUGNUMBER = 1111101;
var summary =
"delete (foo), delete ((foo)), and so on are strict mode early errors";
print(BUGNUMBER + ": " + summary);
/**************
* BEGIN TEST *
**************/
function checkSyntaxError(code)
{
function helper(maker)
{
var earlyError = false;
try
{
var f = maker(code);
var error = "no early error, created a function with code <" + code + ">";
try
{
f();
error += ", and the function can be called without error";
}
catch (e)
{
error +=", and calling the function throws " + e;
}
throw new Error(error);
}
catch (e)
{
assertEq(e instanceof SyntaxError, true,
"expected syntax error, got " + e);
}
}
helper(Function);
helper(eval);
}
checkSyntaxError("function f() { 'use strict'; delete escape; } f();");
checkSyntaxError("function f() { 'use strict'; delete escape; }");
checkSyntaxError("function f() { 'use strict'; delete (escape); } f();");
checkSyntaxError("function f() { 'use strict'; delete (escape); }");
checkSyntaxError("function f() { 'use strict'; delete ((escape)); } f();");
checkSyntaxError("function f() { 'use strict'; delete ((escape)); }");
// Meanwhile, non-strict all of these should work
function checkFine(code)
{
Function(code);
(1, eval)(code); // indirect, to be consistent w/above
}
checkFine("function f() { delete escape; } f();");
checkFine("function f() { delete escape; }");
checkFine("function f() { delete (escape); } f();");
checkFine("function f() { delete (escape); }");
checkFine("function f() { delete ((escape)); } f();");
checkFine("function f() { delete ((escape)); }");
/******************************************************************************/
if (typeof reportCompare === "function")
reportCompare(true, true);
print("Tests complete");
|