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);
    }
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) threw exception TypeError: toISOString did not return a primitive value.
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](JSON)
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;
    }
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: JSON.stringify cannot serialize cyclic structures..
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: JSON.stringify cannot serialize cyclic structures..
function (jsonObject) {
        cycleTracker = "";
        try { jsonObject.stringify(cyclicArray); } catch(e) { 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 < 2048; 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 < 2048; i++)
            deepArray = [deepArray];
        return jsonObject.stringify(deepArray);
    }
PASS tests[i](nativeJSON) is tests[i](JSON)
function (jsonObject) {
        var depth = 0;
        function toDeepVirtualJSONObject() {
            if (++depth >= 2048)
                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 >= 2048)
                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

