js/src/tests/ecma_5/JSON/stringify-replacer-array-duplicated-element.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/tests/ecma_5/JSON/stringify-replacer-array-duplicated-element.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,69 @@
     1.4 +// Any copyright is dedicated to the Public Domain.
     1.5 +// http://creativecommons.org/licenses/publicdomain/
     1.6 +
     1.7 +var gTestfile = 'stringify-replacer-array-hijinks.js';
     1.8 +//-----------------------------------------------------------------------------
     1.9 +var BUGNUMBER = 648471;
    1.10 +var summary =
    1.11 +  "Better/more correct handling for replacer arrays with getter array index " +
    1.12 +  "properties";
    1.13 +
    1.14 +print(BUGNUMBER + ": " + summary);
    1.15 +
    1.16 +/**************
    1.17 + * BEGIN TEST *
    1.18 + **************/
    1.19 +
    1.20 +var bigOdd = Math.pow(2, 50) + 1;
    1.21 +
    1.22 +function two()
    1.23 +{
    1.24 +  return Math.random() < 0.5 ? 2 : "2";
    1.25 +}
    1.26 +
    1.27 +assertEq(JSON.stringify({ 1: 1 }, [1, 1]), '{"1":1}');
    1.28 +
    1.29 +assertEq(JSON.stringify({ 1: 1 }, [1, "1"]), '{"1":1}');
    1.30 +
    1.31 +assertEq(JSON.stringify({ 1: 1 }, [1, bigOdd % two()]), '{"1":1}');
    1.32 +
    1.33 +assertEq(JSON.stringify({ 1: 1 }, ["1", 1]), '{"1":1}');
    1.34 +
    1.35 +assertEq(JSON.stringify({ 1: 1 }, ["1", "1"]), '{"1":1}');
    1.36 +
    1.37 +assertEq(JSON.stringify({ 1: 1 }, ["1", bigOdd % two()]), '{"1":1}');
    1.38 +
    1.39 +assertEq(JSON.stringify({ 1: 1 }, [bigOdd % two(), 1]), '{"1":1}');
    1.40 +
    1.41 +assertEq(JSON.stringify({ 1: 1 }, [bigOdd % two(), "1"]), '{"1":1}');
    1.42 +
    1.43 +assertEq(JSON.stringify({ 1: 1 }, [bigOdd % two(), bigOdd % two()]), '{"1":1}');
    1.44 +
    1.45 +
    1.46 +assertEq(JSON.stringify({ 1: 1 }, [1, new String(1)]), '{"1":1}');
    1.47 +
    1.48 +assertEq(JSON.stringify({ 1: 1 }, [1, new Number(1)]), '{"1":1}');
    1.49 +
    1.50 +assertEq(JSON.stringify({ 1: 1 }, ["1", new Number(1)]), '{"1":1}');
    1.51 +
    1.52 +assertEq(JSON.stringify({ 1: 1 }, ["1", new String(1)]), '{"1":1}');
    1.53 +
    1.54 +assertEq(JSON.stringify({ 1: 1 }, [bigOdd % two(), new Number(1)]), '{"1":1}');
    1.55 +
    1.56 +assertEq(JSON.stringify({ 1: 1 }, [bigOdd % two(), new String(1)]), '{"1":1}');
    1.57 +
    1.58 +
    1.59 +assertEq(JSON.stringify({ 1: 1 }, [new String(1), new String(1)]), '{"1":1}');
    1.60 +
    1.61 +assertEq(JSON.stringify({ 1: 1 }, [new String(1), new Number(1)]), '{"1":1}');
    1.62 +
    1.63 +assertEq(JSON.stringify({ 1: 1 }, [new Number(1), new String(1)]), '{"1":1}');
    1.64 +
    1.65 +assertEq(JSON.stringify({ 1: 1 }, [new Number(1), new Number(1)]), '{"1":1}');
    1.66 +
    1.67 +/******************************************************************************/
    1.68 +
    1.69 +if (typeof reportCompare === "function")
    1.70 +  reportCompare(true, true);
    1.71 +
    1.72 +print("Tests complete");

mercurial