forked from chakra-core/ChakraCore
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreplacerFunction.js
More file actions
39 lines (30 loc) · 1011 Bytes
/
replacerFunction.js
File metadata and controls
39 lines (30 loc) · 1011 Bytes
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
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------
var TEST = function(a, b) {
if (a != b) {
throw new Error(a + " != " + b);
}
}
var obj = { str:6 };
obj[0] = 'value0'
obj[6] = 'value6';
TEST(JSON.stringify(obj, function(k, v) {
if (!k) return v;
return v + 1
}), '{"0":"value01","6":"value61","str":7}');
// test ObjectArray
TEST(JSON.stringify({0:0, 1:1, "two":2}), '{"0":0,"1":1,"two":2}')
var a = new Object();
function replacer(k, v)
{
return v;
}
var until = (WScript.Platform.BUILD_TYPE == 'Debug') ? 12 : 1290;
for (var i = 0; i < until; i++)
{
a[i + 10] = 0;
}
TEST(JSON.stringify(a, replacer).substring(0,20), '{"10":0,"11":0,"12":');
console.log("PASS")