-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
Copy patharr_bailout.js
48 lines (41 loc) · 987 Bytes
/
arr_bailout.js
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
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------
var A = new Array(10);
A[1] = 100;
Array.prototype[5] = 50;
var Failed = 0;
function FAIL()
{
Failed++;
WScript.Echo("FAILED");
}
function foo(arr, i, expected)
{
var z = 0;
for(var j = 0;j<10;j++){
arr = arr[i];
z += arr + 10;
arr = A;
}
if (z != expected)
{
FAIL();
}
return i;
}
// generate profile
for(var i=0;i<200;i++)
{
foo(A, 5, 600);
}
Object.defineProperty(A,5,{get:function(){return 200}});
for(var i=0;i<200;i++)
{
foo(A, 5, 2100);
}
if (!Failed)
{
WScript.Echo("Passed");
}