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
|
load(libdir + 'asserts.js');
load(libdir + 'eqArrayHelper.js');
var reserved = [
'break',
'do',
'in',
'typeof',
'case',
'else',
'instanceof',
'var',
'catch',
'export',
'new',
'void',
'class',
'extends',
'return',
'while',
'const',
'finally',
'super',
'with',
'continue',
'for',
'switch',
'debugger',
'function',
'this',
'delete',
'import',
'try',
'enum',
'null',
'true',
'false'
];
reserved.forEach(ident => {
assertThrowsInstanceOf(() => new Function('var [...' + ident + '] = []'), SyntaxError);
});
var strictIdentifiers = [
'yield',
'let',
'eval',
'arguments',
'implements',
'interface',
'package',
'private',
'protected',
'public',
'static'
];
strictIdentifiers.forEach(ident =>
assertThrowsInstanceOf(() =>
new Function('"use strict"; [...' + ident + '] = []'), SyntaxError));
var globalEval = eval;
strictIdentifiers.forEach(ident => {
globalEval(ident + ' = null');
assertEqArray(new Function('input', '[, ...' + ident + '] = input;' +
'return ' + ident
)([1, 2, 3]), [2, 3]);
});
|