michael@0: // Any copyright is dedicated to the Public Domain. michael@0: // http://creativecommons.org/licenses/publicdomain/ michael@0: michael@0: var gTestfile = 'stringify-replacer-array-skipped-element.js'; michael@0: //----------------------------------------------------------------------------- michael@0: var BUGNUMBER = 648471; michael@0: var summary = michael@0: "Better/more correct handling for replacer arrays with getter array index " + michael@0: "properties"; michael@0: michael@0: print(BUGNUMBER + ": " + summary); michael@0: michael@0: /************** michael@0: * BEGIN TEST * michael@0: **************/ michael@0: michael@0: assertEq(JSON.stringify({ 3: 3, 4: 4 }, michael@0: ["3", { toString: function() { return "4" } }]), michael@0: '{"3":3}'); michael@0: michael@0: assertEq(JSON.stringify({ 3: 3, true: 4 }, ["3", true]), michael@0: '{"3":3}'); michael@0: michael@0: assertEq(JSON.stringify({ 3: 3, true: 4 }, ["3", "true", true]), michael@0: '{"3":3,"true":4}'); michael@0: michael@0: assertEq(JSON.stringify({ 3: 3, true: 4 }, ["3", true, "true"]), michael@0: '{"3":3,"true":4}'); michael@0: michael@0: assertEq(JSON.stringify({ 3: 3, false: 4 }, ["3", false]), michael@0: '{"3":3}'); michael@0: michael@0: assertEq(JSON.stringify({ 3: 3, false: 4 }, ["3", "false", false]), michael@0: '{"3":3,"false":4}'); michael@0: michael@0: assertEq(JSON.stringify({ 3: 3, false: 4 }, ["3", false, "false"]), michael@0: '{"3":3,"false":4}'); michael@0: michael@0: assertEq(JSON.stringify({ 3: 3, undefined: 4 }, ["3", undefined]), michael@0: '{"3":3}'); michael@0: michael@0: assertEq(JSON.stringify({ 3: 3, undefined: 4 }, ["3", "undefined", undefined]), michael@0: '{"3":3,"undefined":4}'); michael@0: michael@0: assertEq(JSON.stringify({ 3: 3, undefined: 4 }, ["3", undefined, "undefined"]), michael@0: '{"3":3,"undefined":4}'); michael@0: michael@0: assertEq(JSON.stringify({ 3: 3, null: 4 }, ["3", null]), michael@0: '{"3":3}'); michael@0: michael@0: assertEq(JSON.stringify({ 3: 3, null: 4 }, ["3", "null", null]), michael@0: '{"3":3,"null":4}'); michael@0: michael@0: assertEq(JSON.stringify({ 3: 3, null: 4 }, ["3", null, "null"]), michael@0: '{"3":3,"null":4}'); michael@0: michael@0: /******************************************************************************/ michael@0: michael@0: if (typeof reportCompare === "function") michael@0: reportCompare(true, true); michael@0: michael@0: print("Tests complete");