blob: f62adb07b2ec2f4026cf38bc522f3d0a79d5f226 [file] [log] [blame]
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 2; }
return jsonObject.stringify(value);
}
FAIL tests[i](nativeJSON) should be 2. Was true.
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 {}; }});
}
FAIL tests[i](nativeJSON) should throw an exception. Was {}.
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;
}
FAIL tests[i](nativeJSON) should be false. Was true.
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);
}
FAIL tests[i](nativeJSON) should be {"foo":1}. Was {}.
function (jsonObject){
return jsonObject.stringify(objectWithSideEffectGetterAndProto);
}
FAIL tests[i](nativeJSON) should be {"foo":1}. Was {}.
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;
}
FAIL tests[i](nativeJSON) should be (string)[1,2,3,null,null,null,4,5,6];0(number)1;1(number)2;2(number)3;3(number)undefined;4(number)undefined;5(number)undefined;6(number)4;7(number)5;8(number)6;. Was (string)[1,2,3,null,null,null,4,5,6];0(string)1;1(string)2;2(string)3;3(string)undefined;4(string)undefined;5(string)undefined;6(string)4;7(string)5;8(string)6;.
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.
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.
function (jsonObject){
cycleTracker = "";
try { jsonObject.stringify(cyclicArray); } catch(e) { cycleTracker += " -> exception" }
return cycleTracker;
}
FAIL tests[i](nativeJSON) should be 0(number):[object Object]first, -> exception. Was 0(string):[object Object]first, -> exception.
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 < 1000; 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 < 1024; i++)
deepArray = [deepArray];
return jsonObject.stringify(deepArray);
}
PASS tests[i](nativeJSON) is tests[i](JSON)
function (jsonObject){
var depth = 0;
function toDeepVirtualJSONObject() {
if (++depth >= 1000)
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