|
1 // Any copyright is dedicated to the Public Domain. |
|
2 // http://creativecommons.org/licenses/publicdomain/ |
|
3 |
|
4 var gTestfile = 'stringify-replacer-array-hijinks.js'; |
|
5 //----------------------------------------------------------------------------- |
|
6 var BUGNUMBER = 648471; |
|
7 var summary = |
|
8 "Better/more correct handling for replacer arrays with getter array index " + |
|
9 "properties"; |
|
10 |
|
11 print(BUGNUMBER + ": " + summary); |
|
12 |
|
13 /************** |
|
14 * BEGIN TEST * |
|
15 **************/ |
|
16 |
|
17 var bigOdd = Math.pow(2, 50) + 1; |
|
18 |
|
19 function two() |
|
20 { |
|
21 return Math.random() < 0.5 ? 2 : "2"; |
|
22 } |
|
23 |
|
24 assertEq(JSON.stringify({ 1: 1 }, [1, 1]), '{"1":1}'); |
|
25 |
|
26 assertEq(JSON.stringify({ 1: 1 }, [1, "1"]), '{"1":1}'); |
|
27 |
|
28 assertEq(JSON.stringify({ 1: 1 }, [1, bigOdd % two()]), '{"1":1}'); |
|
29 |
|
30 assertEq(JSON.stringify({ 1: 1 }, ["1", 1]), '{"1":1}'); |
|
31 |
|
32 assertEq(JSON.stringify({ 1: 1 }, ["1", "1"]), '{"1":1}'); |
|
33 |
|
34 assertEq(JSON.stringify({ 1: 1 }, ["1", bigOdd % two()]), '{"1":1}'); |
|
35 |
|
36 assertEq(JSON.stringify({ 1: 1 }, [bigOdd % two(), 1]), '{"1":1}'); |
|
37 |
|
38 assertEq(JSON.stringify({ 1: 1 }, [bigOdd % two(), "1"]), '{"1":1}'); |
|
39 |
|
40 assertEq(JSON.stringify({ 1: 1 }, [bigOdd % two(), bigOdd % two()]), '{"1":1}'); |
|
41 |
|
42 |
|
43 assertEq(JSON.stringify({ 1: 1 }, [1, new String(1)]), '{"1":1}'); |
|
44 |
|
45 assertEq(JSON.stringify({ 1: 1 }, [1, new Number(1)]), '{"1":1}'); |
|
46 |
|
47 assertEq(JSON.stringify({ 1: 1 }, ["1", new Number(1)]), '{"1":1}'); |
|
48 |
|
49 assertEq(JSON.stringify({ 1: 1 }, ["1", new String(1)]), '{"1":1}'); |
|
50 |
|
51 assertEq(JSON.stringify({ 1: 1 }, [bigOdd % two(), new Number(1)]), '{"1":1}'); |
|
52 |
|
53 assertEq(JSON.stringify({ 1: 1 }, [bigOdd % two(), new String(1)]), '{"1":1}'); |
|
54 |
|
55 |
|
56 assertEq(JSON.stringify({ 1: 1 }, [new String(1), new String(1)]), '{"1":1}'); |
|
57 |
|
58 assertEq(JSON.stringify({ 1: 1 }, [new String(1), new Number(1)]), '{"1":1}'); |
|
59 |
|
60 assertEq(JSON.stringify({ 1: 1 }, [new Number(1), new String(1)]), '{"1":1}'); |
|
61 |
|
62 assertEq(JSON.stringify({ 1: 1 }, [new Number(1), new Number(1)]), '{"1":1}'); |
|
63 |
|
64 /******************************************************************************/ |
|
65 |
|
66 if (typeof reportCompare === "function") |
|
67 reportCompare(true, true); |
|
68 |
|
69 print("Tests complete"); |