forked from chakra-core/ChakraCore
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharray_length.js
More file actions
123 lines (106 loc) · 2.26 KB
/
array_length.js
File metadata and controls
123 lines (106 loc) · 2.26 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------
function write(args)
{
WScript.Echo(args);
}
var arr=new Array(2);
arr[0]=1;
arr.length="";
write(arr.length);
arr.length=null;
write(arr.length);
arr.length=4294967295;
write(arr.length.toString());
try {
arr.length="-1";
}
catch (e)
{
write(e.message);
}
try {
arr.length=4294967296;
}
catch (e)
{
write(e.message);
}
try {
Array.length=10;
write(Array.length);
}
catch (e)
{
write(e.message);
}
try {
x = [];
x.length = true;
write(x.length);
}
catch(e)
{
write(e.message);
}
try {
Object.prototype.length = function () {
return this
};
(function () {
;
for (var y in [void 0]) {
y.length();
}
})();
}
catch (e) {
write(e.message);
}
try {
Object.prototype.length = function () {
return this
};
var a = [10, 20, 24];
WScript.Echo("prop = " + a.length);
WScript.Echo("method = " + a.length());
}
catch (e) {
write(e.message);
}
var a = { length: 10 };
var b = Object.freeze(a);
var c = Object.create(b);
c.length = 88;
WScript.Echo(c.length);
WScript.Echo(b.length);
var o = Object.freeze([]);
var p = Object.create(o)
p.length = 5
WScript.Echo(p.length);
WScript.Echo(o.length);
var x = [];
var y = Object.create(x);
y.length = 7;
WScript.Echo(y.length);
WScript.Echo(x.length);
var z = [];
z.length = 3;
WScript.Echo(z.length);
function echo(m) { if (this.WScript) { WScript.Echo(m); } else { console.log(m); } }
Object.defineProperty(Object.prototype, "length", { set: function() { echo("setter"); }, configurable: true });
var a = [];
var b = Object.create(a);
b.length = 5;
echo(b.length);
function foo()
{
var arr = new Array(10);
var x = arr.length--;
arr[arr.length + 1] = 20;
var y = --arr.length;
return y;
}
WScript.Echo(foo());