blob: c82c56cf8b1059a02a9ddf9b35ec565c8fe1c570 (
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
|
var caught = false;
try {
new Function("throw;");
} catch (e) {
assertEq(e instanceof SyntaxError, true);
assertEq(e.message.startsWith("throw statement is missing an expression") == -1, false);
caught = true;
}
assertEq(caught, true);
caught = false;
try {
new Function("throw\n1;");
} catch (e) {
assertEq(e instanceof SyntaxError, true);
assertEq(e.message.startsWith("no line break is allowed between 'throw' and its expression") == -1, false);
caught = true;
}
assertEq(caught, true);
caught = false;
try {
new Function("throw}");
} catch (e) {
assertEq(e instanceof SyntaxError, true);
assertEq(e.message.startsWith("throw statement is missing an expression") == -1, false);
caught = true;
}
assertEq(caught, true);
caught = false;
try {
new Function("throw");
} catch (e) {
assertEq(e instanceof SyntaxError, true);
assertEq(e.message.startsWith("throw statement is missing an expression") == -1, false);
caught = true;
}
assertEq(caught, true);
|