forked from facebook/hermes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharguments-usercode.js
More file actions
63 lines (55 loc) · 1.78 KB
/
arguments-usercode.js
File metadata and controls
63 lines (55 loc) · 1.78 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
63
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
// RUN: %hermes -O -target=HBC -serializevm-path=%t %s
// RUN: %hermes -O -deserialize-file=%t -target=HBC %s || %FileCheck --match-full-lines %s
// REQUIRES: serializer
"use strict";
var empty = "";
function simpleArgs() {
for(var i = 0; i < arguments.length; ++i)
print("arg [" + i + "]=" + arguments[i]);
print("invalid arg [" + i + "]=" + arguments[i]);
i = "foo" + i;
print("invalid arg [" + i + "]=" + arguments[i]);
i = empty + "length";
print("indirect length [" + i + "]=" + arguments[i]);
i = empty + "foo";
print("parent prop foo [" + i + "]=" + arguments[i]);
// This will cause reification since it is an accessor.
i = empty + "__proto__";
print("indirect __proto__ [" + i + "]=" + arguments[i]);
// Read the same parent property again.
i = empty + "foo";
print("parent prop foo [" + i + "]=" + arguments[i]);
}
Object.prototype.foo = "foo-val";
function modifyArgs(i) {
++arguments[i];
print(arguments[i]);
print(arguments[i+1]);
++arguments.length;
print(arguments.length);
arguments.foo = "bar";
print(arguments.foo);
}
serializeVM(function() {
simpleArgs(10,20,30);
//CHECK:arg [0]=10
//CHECK-NEXT:arg [1]=20
//CHECK-NEXT:arg [2]=30
//CHECK-NEXT:invalid arg [3]=undefined
//CHECK-NEXT:invalid arg [foo3]=undefined
//CHECK-NEXT:indirect length [length]=3
//CHECK-NEXT:parent prop foo [foo]=foo-val
//CHECK-NEXT:indirect __proto__ [__proto__]=[object Object]
//CHECK-NEXT:parent prop foo [foo]=foo-val
modifyArgs(1, 20, 30);
//CHECK-NEXT:21
//CHECK-NEXT:30
//CHECK-NEXT:4
//CHECK-NEXT:bar
})