| function (jsonObject){ |
| return jsonObject.stringify(1); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify(1.5); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify(-1); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify(-1.5); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify(null); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify("string"); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify(new Number(0)); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify(new Number(1)); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify(new Number(1.5)); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify(new Number(-1)); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify(new Number(-1.5)); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify(new String("a string object")); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify(new Boolean(true)); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| var value = new Number(1); |
| value.valueOf = function() { return 2; }; |
| return jsonObject.stringify(value); |
| } |
| PASS tests[i](nativeJSON) is tests[i].expected |
| function (jsonObject){ |
| var value = new Boolean(true); |
| value.valueOf = function() { return false; }; |
| return jsonObject.stringify(value); |
| } |
| PASS tests[i](nativeJSON) is tests[i].expected |
| function (jsonObject){ |
| var value = new String("fail"); |
| value.toString = function() { return "converted string"; }; |
| return jsonObject.stringify(value); |
| } |
| PASS tests[i](nativeJSON) is tests[i].expected |
| function (jsonObject){ |
| return jsonObject.stringify(true); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify(false); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify(new Date(0)); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify({toJSON: Date.prototype.toJSON}); |
| } |
| PASS tests[i](nativeJSON) threw exception TypeError: toISOString is not a function. |
| function (jsonObject){ |
| return jsonObject.stringify({toJSON: Date.prototype.toJSON, toISOString: function(){ return "custom toISOString"; }}); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify({toJSON: Date.prototype.toJSON, toISOString: function(){ return {}; }}); |
| } |
| PASS tests[i](nativeJSON) is tests[i].expected |
| function (jsonObject){ |
| return jsonObject.stringify({toJSON: Date.prototype.toJSON, toISOString: function(){ throw "An exception"; }}); |
| } |
| PASS tests[i](nativeJSON) threw exception An exception. |
| function (jsonObject){ |
| var d = new Date(0); |
| d.toISOString = null; |
| return jsonObject.stringify(d); |
| } |
| PASS tests[i](nativeJSON) threw exception TypeError: toISOString is not a function. |
| function (jsonObject){ |
| var d = new Date(0); |
| d.toJSON = undefined; |
| return jsonObject.stringify(d); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify({get Foo() { return "bar"; }}); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify({get Foo() { this.foo="wibble"; return "bar"; }}); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| var count = 0; |
| jsonObject.stringify({get Foo() { count++; return "bar"; }}); |
| return count; |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| var count = 0; |
| return jsonObject.stringify({get Foo() { count++; delete this.bar; return "bar"; }, bar: "wibble"}); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| var count = 0; |
| return jsonObject.stringify({a:"1", b:"2", c:"3", 5:4, 4:5, 2:6, 1:7}); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| var allString = true; |
| jsonObject.stringify({a:"1", b:"2", c:"3", 5:4, 4:5, 2:6, 1:7}, function(k,v){allString = allString && (typeof k == "string"); return v}); |
| return allString; |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| var allString = true; |
| jsonObject.stringify([1,2,3,4,5], function(k,v){allString = allString && (typeof k == "string"); return v}); |
| return allString; |
| } |
| PASS tests[i](nativeJSON) is tests[i].expected |
| function (jsonObject){ |
| var allString = true; |
| var array = []; |
| return jsonObject.stringify({a:"1", b:"2", c:"3", 5:4, 4:5, 2:6, 1:7}, array); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| var allString = true; |
| var array = ["a"]; |
| return jsonObject.stringify({get a(){return 1;array[1]="b";array[2]="c"}, b:"2", c:"3"}, array); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| var allString = true; |
| var array = [{toString:function(){array[0]='a'; array[1]='c'; array[2]='b'; return 'a'}}]; |
| return jsonObject.stringify(simpleObject, array); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| var allString = true; |
| var array = [{toString:function(){array[0]='a'; array[1]='c'; array[2]='b'; return 'a'}}]; |
| return jsonObject.stringify(simpleObjectWithProto, array); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| var allString = true; |
| var array = [1, new Number(2), NaN, Infinity, -Infinity, new String("str")]; |
| return jsonObject.stringify({"1":"1","2":"2","NaN":"NaN","Infinity":"Infinity","-Infinity":"-Infinity","str":"str"}, array); |
| } |
| PASS tests[i](nativeJSON) is tests[i].expected |
| function (jsonObject){ |
| var allString = true; |
| var array = ["1","2","3"]; |
| return jsonObject.stringify({1:'a', 2:'b', 3:'c'}, array); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| var allString = true; |
| var array = ["1","2","3"]; |
| return jsonObject.stringify(simpleArray, array); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify(simpleArray, null, " "); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify(simpleArray, null, 4); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify(simpleArray, null, "ab"); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify(simpleArray, null, 4); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify(simpleObject, null, " "); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify(simpleObject, null, 4); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify(simpleObject, null, "ab"); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify(simpleObject, null, 4); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify(simpleObject, null, 10); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify(simpleObject, null, 11); |
| } |
| PASS tests[i](nativeJSON) is tests[i].expected |
| function (jsonObject){ |
| return jsonObject.stringify(simpleObject, null, " "); |
| } |
| PASS tests[i](nativeJSON) is tests[i].expected |
| function (jsonObject){ |
| return jsonObject.stringify(simpleObject, null, " "); |
| } |
| PASS tests[i](nativeJSON) is tests[i].expected |
| function (jsonObject){ |
| return jsonObject.stringify(complexArray, null, " "); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify(complexArray, null, 4); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify(complexArray, null, "ab"); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify(complexArray, null, 4); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify(complexObject, null, " "); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify(complexObject, null, 4); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify(complexObject, null, "ab"); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify(complexObject, null, 4); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| var allString = true; |
| var array = ["1","2","3"]; |
| return jsonObject.stringify(simpleArrayWithProto, array); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify(simpleArrayWithProto, null, " "); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify(simpleArrayWithProto, null, 4); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify(simpleArrayWithProto, null, "ab"); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify(simpleArrayWithProto, null, 4); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify(simpleObjectWithProto, null, " "); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify(simpleObjectWithProto, null, 4); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify(simpleObjectWithProto, null, "ab"); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify(simpleObjectWithProto, null, 4); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify(simpleObjectWithProto, null, 10); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify(simpleObjectWithProto, null, 11); |
| } |
| PASS tests[i](nativeJSON) is tests[i].expected |
| function (jsonObject){ |
| return jsonObject.stringify(simpleObjectWithProto, null, " "); |
| } |
| PASS tests[i](nativeJSON) is tests[i].expected |
| function (jsonObject){ |
| return jsonObject.stringify(simpleObjectWithProto, null, " "); |
| } |
| PASS tests[i](nativeJSON) is tests[i].expected |
| function (jsonObject){ |
| return jsonObject.stringify(complexArrayWithProto, null, " "); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify(complexArrayWithProto, null, 4); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify(complexArrayWithProto, null, "ab"); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify(complexArrayWithProto, null, 4); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify(complexObjectWithProto, null, " "); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify(complexObjectWithProto, null, 4); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify(complexObjectWithProto, null, "ab"); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify(complexObjectWithProto, null, 4); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify(objectWithSideEffectGetter); |
| } |
| PASS tests[i](nativeJSON) is tests[i].expected |
| function (jsonObject){ |
| return jsonObject.stringify(objectWithSideEffectGetterAndProto); |
| } |
| PASS tests[i](nativeJSON) is tests[i].expected |
| function (jsonObject){ |
| return jsonObject.stringify(arrayWithSideEffectGetter); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify(arrayWithSideEffectGetterAndProto); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| replaceTracker = ""; |
| jsonObject.stringify([1,2,3,,,,4,5,6], replaceFunc); |
| return replaceTracker; |
| } |
| PASS tests[i](nativeJSON) is tests[i].expected |
| function (jsonObject){ |
| replaceTracker = ""; |
| jsonObject.stringify({a:"a", b:"b", c:"c", 3: "d", 2: "e", 1: "f"}, replaceFunc); |
| return replaceTracker; |
| } |
| PASS tests[i](nativeJSON) is tests[i].expected |
| function (jsonObject){ |
| var count = 0; |
| var array = [{toString:function(){count++; array[0]='a'; array[1]='c'; array[2]='b'; return 'a'}}]; |
| jsonObject.stringify(simpleObject, array); |
| return count; |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| var allString = true; |
| var array = [{toString:function(){array[0]='a'; array[1]='c'; array[2]='b'; return 'a'}}, 'b', 'c']; |
| return jsonObject.stringify(simpleObject, array); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| var count = 0; |
| var array = [{toString:function(){count++; array[0]='a'; array[1]='c'; array[2]='b'; return 'a'}}, 'b', 'c']; |
| jsonObject.stringify(simpleObject, array); |
| return count; |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify({a:"1", get b() { this.a="foo"; return "getter"; }, c:"3"}); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify({a:"1", get b() { this.c="foo"; return "getter"; }, c:"3"}); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| var setterCalled = false; |
| jsonObject.stringify({a:"1", set b(s) { setterCalled = true; return "setter"; }, c:"3"}); |
| return setterCalled; |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify({a:"1", get b(){ return "getter"; }, set b(s) { return "setter"; }, c:"3"}); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify(new Array(10)); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify([undefined,,null,0,false]); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify({p1:undefined,p2:null,p3:0,p4:false}); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| cycleTracker = ""; |
| return jsonObject.stringify(cyclicObject); |
| } |
| PASS tests[i](nativeJSON) threw exception TypeError: Converting circular structure to JSON |
| --> starting at object with constructor 'Object' |
| --- property 'self' closes the circle. |
| function (jsonObject){ |
| cycleTracker = ""; |
| try { jsonObject.stringify(cyclicObject); } catch(e) { cycleTracker += " -> exception" } |
| return cycleTracker; |
| } |
| PASS tests[i](nativeJSON) is tests[i].expected |
| function (jsonObject){ |
| cycleTracker = ""; |
| return jsonObject.stringify(cyclicArray); |
| } |
| PASS tests[i](nativeJSON) threw exception TypeError: Converting circular structure to JSON |
| --> starting at object with constructor 'Array' |
| --- index 1 closes the circle. |
| function (jsonObject){ |
| cycleTracker = ""; |
| try { jsonObject.stringify(cyclicArray); } catch { cycleTracker += " -> exception" } |
| return cycleTracker; |
| } |
| PASS tests[i](nativeJSON) is tests[i].expected |
| function (jsonObject){ |
| getterCalls = 0; |
| return jsonObject.stringify(magicObject) + " :: getter calls = " + getterCalls; |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify(undefined); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify(null); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify({toJSON:function(){ return undefined; }}); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify({toJSON:function(){ return null; }}); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify([{toJSON:function(){ return undefined; }}]); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify([{toJSON:function(){ return null; }}]); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify({a:{toJSON:function(){ return undefined; }}}); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify({a:{toJSON:function(){ return null; }}}); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify({a:{toJSON:function(){ return function(){}; }}}); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| return jsonObject.stringify({a:function(){}}); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| var deepObject = {}; |
| for (var i = 0; i < 700; i++) |
| deepObject = {next:deepObject}; |
| return jsonObject.stringify(deepObject); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| var deepArray = []; |
| for (var i = 0; i < 800; i++) |
| deepArray = [deepArray]; |
| return jsonObject.stringify(deepArray); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| var depth = 0; |
| function toDeepVirtualJSONObject() { |
| if (++depth >= 700) |
| return {}; |
| var r = {}; |
| r.toJSON = toDeepVirtualJSONObject; |
| return {recurse: r}; |
| } |
| return jsonObject.stringify(toDeepVirtualJSONObject()); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| function (jsonObject){ |
| var depth = 0; |
| function toDeepVirtualJSONArray() { |
| if (++depth >= 1024) |
| return []; |
| var r = []; |
| r.toJSON = toDeepJSONArray; |
| return [r]; |
| } |
| return jsonObject.stringify(toDeepVirtualJSONArray()); |
| } |
| function (jsonObject){ |
| return jsonObject.stringify(fullCharsetString); |
| } |
| PASS tests[i](nativeJSON) is tests[i](JSON) |
| PASS successfullyParsed is true |
| |
| TEST COMPLETE |