Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
134 lines (106 loc) · 2.44 KB

File metadata and controls

134 lines (106 loc) · 2.44 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
124
125
126
127
128
129
130
131
132
133
134
//-------------------------------------------------------------------------------------------------------
// 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);
}
write("Scenario 0");
//Array sort testing to make sure no change for Strings
var s = new String("world hello");
s.foo = Array.prototype.sort;
try
{
s.foo();
}
catch (e)
{
if (! e instanceof TypeError)
throw e;
write(s);
}
//following scenario's test sparse array, prototype lookup and undefined elements
write("Scenario 1");
var a = [undefined, undefined, undefined];
a.sort();
write(a);
write(a.length);
write("Scenario 2");
var b = undefined;
var a = [b, b];
a[10] = b;
a[11] = b;
a[21] = b;
a[22] = b;
a[8] = b;
a.sort();
write(a);
write(a.length);
write("Scenario 3");
var b = undefined;
var a = [b];
a.sort();
write(a);
write(a.length);
write("Scenario 4 - prototype lookup - output in cscript is different");
for(var i = 0;i<20;i=i+4)
{
Object.prototype[i] = "o"+i;
}
for(var i = 0;i<20;i=i+3)
{
Array.prototype[i] = "p"+i;
}
Array.prototype[14] = undefined;
Object.prototype[2] = undefined;
var a = [23,14, undefined, 17];
a[10] = 5;
a[11] = 22;
a[12] = undefined;
a[13] = 20;
write(a.sort());
write(a);
write(a.length);
write("Scenario 5 - prototype lookup");
var arr=new Array(3)
write(arr.sort());
write(arr);
Array.prototype[0]=0;
Array.prototype[1]=0;
Array.prototype[2]=0;
write(arr.length);
write("Scenario 6 - prototype lookup");
Array.prototype[5]=10;
Array.prototype[6]=1;
Array.prototype[7]=15;
var arr=new Array(8)
arr[0]=1;
arr[1]=2;
arr[2]=3;
write(arr.sort());
write("Scenario 7 - output in cscript is different");
Array.prototype[5]=10;
var arr=new Array(8)
arr[1]=1;
arr[5]=undefined;
arr.sort();
write(arr)
write("Scenario 8");
Array.prototype[12]=10;
var arr=new Array(8)
arr[1]=1;
write(arr.sort());
write(arr);
function comparefn(x,y) { arr[0]="test"; return x - y; }
var arr=new Array(2);
arr[0]=12;
arr[1]=10;
arr.sort(comparefn);
write(arr);
function comparefn(x, y) { delete arr[0]; return x - y; }
var arr=new Array(3);
arr[0]=12;
arr[2]=10;
arr.sort(comparefn);
write(arr);
Morty Proxy This is a proxified and sanitized view of the page, visit original site.