forked from svaarala/duktape
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-arguments-binding.js
More file actions
62 lines (52 loc) · 1.12 KB
/
test-arguments-binding.js
File metadata and controls
62 lines (52 loc) · 1.12 KB
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
/*
* Some 'arguments' binding tests
*/
/*===
object
number
object
false
object
===*/
/* A non-strict 'arguments' binding is writable but not deletable. */
function arguments_write() {
print(typeof arguments);
arguments = 1;
print(typeof arguments);
}
function arguments_delete() {
print(typeof arguments);
print(delete arguments);
print(typeof arguments);
}
try {
arguments_write();
} catch (e) {
print(e.name);
}
try {
arguments_delete();
} catch (e) {
print(e.name);
}
/*===
SyntaxError
SyntaxError
===*/
/* A strict 'arguments' binding is immutable. It cannot be deleted nor can
* it be assigned to; doing so would be a SyntaxError.
*
* XXX: how to test that the binding is actually immutable, as it is a
* SyntaxError trying to delete it or assign to it? Even an eval() call
* does not work: the eval will be parsed in strict mode too.
*/
try {
eval("function arguments_strict_delete() { 'use strict'; delete arguments; }");
} catch (e) {
print(e.name);
}
try {
eval("function arguments_strict_delete() { 'use strict'; arguments = 1; }");
} catch (e) {
print(e.name);
}