1function (jsonObject){
2        return jsonObject.stringify(1);
3    }
4PASS tests[i](nativeJSON) is tests[i](JSON)
5function (jsonObject){
6        return jsonObject.stringify(1.5);
7    }
8PASS tests[i](nativeJSON) is tests[i](JSON)
9function (jsonObject){
10        return jsonObject.stringify(-1);
11    }
12PASS tests[i](nativeJSON) is tests[i](JSON)
13function (jsonObject){
14        return jsonObject.stringify(-1.5);
15    }
16PASS tests[i](nativeJSON) is tests[i](JSON)
17function (jsonObject){
18        return jsonObject.stringify(null);
19    }
20PASS tests[i](nativeJSON) is tests[i](JSON)
21function (jsonObject){
22        return jsonObject.stringify("string");
23    }
24PASS tests[i](nativeJSON) is tests[i](JSON)
25function (jsonObject){
26        return jsonObject.stringify(new Number(0));
27    }
28PASS tests[i](nativeJSON) is tests[i](JSON)
29function (jsonObject){
30        return jsonObject.stringify(new Number(1));
31    }
32PASS tests[i](nativeJSON) is tests[i](JSON)
33function (jsonObject){
34        return jsonObject.stringify(new Number(1.5));
35    }
36PASS tests[i](nativeJSON) is tests[i](JSON)
37function (jsonObject){
38        return jsonObject.stringify(new Number(-1));
39    }
40PASS tests[i](nativeJSON) is tests[i](JSON)
41function (jsonObject){
42        return jsonObject.stringify(new Number(-1.5));
43    }
44PASS tests[i](nativeJSON) is tests[i](JSON)
45function (jsonObject){
46        return jsonObject.stringify(new String("a string object"));
47    }
48PASS tests[i](nativeJSON) is tests[i](JSON)
49function (jsonObject){
50        return jsonObject.stringify(new Boolean(true));
51    }
52PASS tests[i](nativeJSON) is tests[i](JSON)
53function (jsonObject){
54        var value = new Number(1);
55        value.valueOf = function() { return 2; }
56        return jsonObject.stringify(value);
57    }
58PASS tests[i](nativeJSON) is tests[i].expected
59function (jsonObject){
60        var value = new Boolean(true);
61        value.valueOf = function() { return 2; }
62        return jsonObject.stringify(value);
63    }
64FAIL tests[i](nativeJSON) should be 2. Was true.
65function (jsonObject){
66        var value = new String("fail");
67        value.toString = function() { return "converted string"; }
68        return jsonObject.stringify(value);
69    }
70PASS tests[i](nativeJSON) is tests[i].expected
71function (jsonObject){
72        return jsonObject.stringify(true);
73    }
74PASS tests[i](nativeJSON) is tests[i](JSON)
75function (jsonObject){
76        return jsonObject.stringify(false);
77    }
78PASS tests[i](nativeJSON) is tests[i](JSON)
79function (jsonObject){
80        return jsonObject.stringify(new Date(0));
81    }
82PASS tests[i](nativeJSON) is tests[i](JSON)
83function (jsonObject){
84        return jsonObject.stringify({toJSON: Date.prototype.toJSON});
85    }
86PASS tests[i](nativeJSON) threw exception TypeError: undefined is not a function.
87function (jsonObject){
88        return jsonObject.stringify({toJSON: Date.prototype.toJSON, toISOString: function(){ return "custom toISOString"; }});
89    }
90PASS tests[i](nativeJSON) is tests[i](JSON)
91function (jsonObject){
92        return jsonObject.stringify({toJSON: Date.prototype.toJSON, toISOString: function(){ return {}; }});
93    }
94FAIL tests[i](nativeJSON) should throw an exception. Was {}.
95function (jsonObject){
96        return jsonObject.stringify({toJSON: Date.prototype.toJSON, toISOString: function(){ throw "An exception"; }});
97    }
98PASS tests[i](nativeJSON) threw exception An exception.
99function (jsonObject){
100        var d = new Date(0);
101        d.toISOString = null;
102        return jsonObject.stringify(d);
103    }
104PASS tests[i](nativeJSON) threw exception TypeError: object is not a function.
105function (jsonObject){
106        var d = new Date(0);
107        d.toJSON = undefined;
108        return jsonObject.stringify(d);
109    }
110PASS tests[i](nativeJSON) is tests[i](JSON)
111function (jsonObject){
112        return jsonObject.stringify({get Foo() { return "bar"; }});
113    }
114PASS tests[i](nativeJSON) is tests[i](JSON)
115function (jsonObject){
116        return jsonObject.stringify({get Foo() { this.foo="wibble"; return "bar"; }});
117    }
118PASS tests[i](nativeJSON) is tests[i](JSON)
119function (jsonObject){
120        var count = 0;
121        jsonObject.stringify({get Foo() { count++; return "bar"; }});
122        return count;
123    }
124PASS tests[i](nativeJSON) is tests[i](JSON)
125function (jsonObject){
126        var count = 0;
127        return jsonObject.stringify({get Foo() { count++; delete this.bar; return "bar"; }, bar: "wibble"});
128    }
129PASS tests[i](nativeJSON) is tests[i](JSON)
130function (jsonObject){
131        var count = 0;
132        return jsonObject.stringify({a:"1", b:"2", c:"3", 5:4, 4:5, 2:6, 1:7});
133    }
134PASS tests[i](nativeJSON) is tests[i](JSON)
135function (jsonObject){
136        var allString = true;
137        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});
138        return allString;
139    }
140PASS tests[i](nativeJSON) is tests[i](JSON)
141function (jsonObject){
142        var allString = true;
143        jsonObject.stringify([1,2,3,4,5], function(k,v){allString = allString && (typeof k == "string"); return v});
144        return allString;
145    }
146FAIL tests[i](nativeJSON) should be false. Was true.
147function (jsonObject){
148        var allString = true;
149        var array = [];
150        return jsonObject.stringify({a:"1", b:"2", c:"3", 5:4, 4:5, 2:6, 1:7}, array);
151    }
152PASS tests[i](nativeJSON) is tests[i](JSON)
153function (jsonObject){
154        var allString = true;
155        var array = ["a"];
156        return jsonObject.stringify({get a(){return 1;array[1]="b";array[2]="c"}, b:"2", c:"3"}, array);
157    }
158PASS tests[i](nativeJSON) is tests[i](JSON)
159function (jsonObject){
160        var allString = true;
161        var array = [{toString:function(){array[0]='a'; array[1]='c'; array[2]='b'; return 'a'}}];
162        return jsonObject.stringify(simpleObject, array);
163    }
164PASS tests[i](nativeJSON) is tests[i](JSON)
165function (jsonObject){
166        var allString = true;
167        var array = [{toString:function(){array[0]='a'; array[1]='c'; array[2]='b'; return 'a'}}];
168        return jsonObject.stringify(simpleObjectWithProto, array);
169    }
170PASS tests[i](nativeJSON) is tests[i](JSON)
171function (jsonObject){
172        var allString = true;
173        var array = [1, new Number(2), NaN, Infinity, -Infinity, new String("str")];
174        return jsonObject.stringify({"1":"1","2":"2","NaN":"NaN","Infinity":"Infinity","-Infinity":"-Infinity","str":"str"}, array);
175    }
176PASS tests[i](nativeJSON) is tests[i].expected
177function (jsonObject){
178        var allString = true;
179        var array = ["1","2","3"];
180        return jsonObject.stringify({1:'a', 2:'b', 3:'c'}, array);
181    }
182PASS tests[i](nativeJSON) is tests[i](JSON)
183function (jsonObject){
184        var allString = true;
185        var array = ["1","2","3"];
186        return jsonObject.stringify(simpleArray, array);
187    }
188PASS tests[i](nativeJSON) is tests[i](JSON)
189function (jsonObject){
190        return jsonObject.stringify(simpleArray, null, "  ");
191    }
192PASS tests[i](nativeJSON) is tests[i](JSON)
193function (jsonObject){
194        return jsonObject.stringify(simpleArray, null, 4);
195    }
196PASS tests[i](nativeJSON) is tests[i](JSON)
197function (jsonObject){
198        return jsonObject.stringify(simpleArray, null, "ab");
199    }
200PASS tests[i](nativeJSON) is tests[i](JSON)
201function (jsonObject){
202        return jsonObject.stringify(simpleArray, null, 4);
203    }
204PASS tests[i](nativeJSON) is tests[i](JSON)
205function (jsonObject){
206        return jsonObject.stringify(simpleObject, null, "  ");
207    }
208PASS tests[i](nativeJSON) is tests[i](JSON)
209function (jsonObject){
210        return jsonObject.stringify(simpleObject, null, 4);
211    }
212PASS tests[i](nativeJSON) is tests[i](JSON)
213function (jsonObject){
214        return jsonObject.stringify(simpleObject, null, "ab");
215    }
216PASS tests[i](nativeJSON) is tests[i](JSON)
217function (jsonObject){
218        return jsonObject.stringify(simpleObject, null, 4);
219    }
220PASS tests[i](nativeJSON) is tests[i](JSON)
221function (jsonObject){
222        return jsonObject.stringify(simpleObject, null, 10);
223    }
224PASS tests[i](nativeJSON) is tests[i](JSON)
225function (jsonObject){
226        return jsonObject.stringify(simpleObject, null, 11);
227    }
228PASS tests[i](nativeJSON) is tests[i].expected
229function (jsonObject){
230        return jsonObject.stringify(simpleObject, null, "          ");
231    }
232PASS tests[i](nativeJSON) is tests[i].expected
233function (jsonObject){
234        return jsonObject.stringify(simpleObject, null, "           ");
235    }
236PASS tests[i](nativeJSON) is tests[i].expected
237function (jsonObject){
238        return jsonObject.stringify(complexArray, null, "  ");
239    }
240PASS tests[i](nativeJSON) is tests[i](JSON)
241function (jsonObject){
242        return jsonObject.stringify(complexArray, null, 4);
243    }
244PASS tests[i](nativeJSON) is tests[i](JSON)
245function (jsonObject){
246        return jsonObject.stringify(complexArray, null, "ab");
247    }
248PASS tests[i](nativeJSON) is tests[i](JSON)
249function (jsonObject){
250        return jsonObject.stringify(complexArray, null, 4);
251    }
252PASS tests[i](nativeJSON) is tests[i](JSON)
253function (jsonObject){
254        return jsonObject.stringify(complexObject, null, "  ");
255    }
256PASS tests[i](nativeJSON) is tests[i](JSON)
257function (jsonObject){
258        return jsonObject.stringify(complexObject, null, 4);
259    }
260PASS tests[i](nativeJSON) is tests[i](JSON)
261function (jsonObject){
262        return jsonObject.stringify(complexObject, null, "ab");
263    }
264PASS tests[i](nativeJSON) is tests[i](JSON)
265function (jsonObject){
266        return jsonObject.stringify(complexObject, null, 4);
267    }
268PASS tests[i](nativeJSON) is tests[i](JSON)
269function (jsonObject){
270        var allString = true;
271        var array = ["1","2","3"];
272        return jsonObject.stringify(simpleArrayWithProto, array);
273    }
274PASS tests[i](nativeJSON) is tests[i](JSON)
275function (jsonObject){
276        return jsonObject.stringify(simpleArrayWithProto, null, "  ");
277    }
278PASS tests[i](nativeJSON) is tests[i](JSON)
279function (jsonObject){
280        return jsonObject.stringify(simpleArrayWithProto, null, 4);
281    }
282PASS tests[i](nativeJSON) is tests[i](JSON)
283function (jsonObject){
284        return jsonObject.stringify(simpleArrayWithProto, null, "ab");
285    }
286PASS tests[i](nativeJSON) is tests[i](JSON)
287function (jsonObject){
288        return jsonObject.stringify(simpleArrayWithProto, null, 4);
289    }
290PASS tests[i](nativeJSON) is tests[i](JSON)
291function (jsonObject){
292        return jsonObject.stringify(simpleObjectWithProto, null, "  ");
293    }
294PASS tests[i](nativeJSON) is tests[i](JSON)
295function (jsonObject){
296        return jsonObject.stringify(simpleObjectWithProto, null, 4);
297    }
298PASS tests[i](nativeJSON) is tests[i](JSON)
299function (jsonObject){
300        return jsonObject.stringify(simpleObjectWithProto, null, "ab");
301    }
302PASS tests[i](nativeJSON) is tests[i](JSON)
303function (jsonObject){
304        return jsonObject.stringify(simpleObjectWithProto, null, 4);
305    }
306PASS tests[i](nativeJSON) is tests[i](JSON)
307function (jsonObject){
308        return jsonObject.stringify(simpleObjectWithProto, null, 10);
309    }
310PASS tests[i](nativeJSON) is tests[i](JSON)
311function (jsonObject){
312        return jsonObject.stringify(simpleObjectWithProto, null, 11);
313    }
314PASS tests[i](nativeJSON) is tests[i].expected
315function (jsonObject){
316        return jsonObject.stringify(simpleObjectWithProto, null, "          ");
317    }
318PASS tests[i](nativeJSON) is tests[i].expected
319function (jsonObject){
320        return jsonObject.stringify(simpleObjectWithProto, null, "           ");
321    }
322PASS tests[i](nativeJSON) is tests[i].expected
323function (jsonObject){
324        return jsonObject.stringify(complexArrayWithProto, null, "  ");
325    }
326PASS tests[i](nativeJSON) is tests[i](JSON)
327function (jsonObject){
328        return jsonObject.stringify(complexArrayWithProto, null, 4);
329    }
330PASS tests[i](nativeJSON) is tests[i](JSON)
331function (jsonObject){
332        return jsonObject.stringify(complexArrayWithProto, null, "ab");
333    }
334PASS tests[i](nativeJSON) is tests[i](JSON)
335function (jsonObject){
336        return jsonObject.stringify(complexArrayWithProto, null, 4);
337    }
338PASS tests[i](nativeJSON) is tests[i](JSON)
339function (jsonObject){
340        return jsonObject.stringify(complexObjectWithProto, null, "  ");
341    }
342PASS tests[i](nativeJSON) is tests[i](JSON)
343function (jsonObject){
344        return jsonObject.stringify(complexObjectWithProto, null, 4);
345    }
346PASS tests[i](nativeJSON) is tests[i](JSON)
347function (jsonObject){
348        return jsonObject.stringify(complexObjectWithProto, null, "ab");
349    }
350PASS tests[i](nativeJSON) is tests[i](JSON)
351function (jsonObject){
352        return jsonObject.stringify(complexObjectWithProto, null, 4);
353    }
354PASS tests[i](nativeJSON) is tests[i](JSON)
355function (jsonObject){
356        return jsonObject.stringify(objectWithSideEffectGetter);
357    }
358FAIL tests[i](nativeJSON) should be {"foo":1}. Was {}.
359function (jsonObject){
360        return jsonObject.stringify(objectWithSideEffectGetterAndProto);
361    }
362FAIL tests[i](nativeJSON) should be {"foo":1}. Was {}.
363function (jsonObject){
364        return jsonObject.stringify(arrayWithSideEffectGetter);
365    }
366PASS tests[i](nativeJSON) is tests[i](JSON)
367function (jsonObject){
368        return jsonObject.stringify(arrayWithSideEffectGetterAndProto);
369    }
370PASS tests[i](nativeJSON) is tests[i](JSON)
371function (jsonObject){
372        replaceTracker = "";
373        jsonObject.stringify([1,2,3,,,,4,5,6], replaceFunc);
374        return replaceTracker;
375    }
376FAIL 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;.
377function (jsonObject){
378        replaceTracker = "";
379        jsonObject.stringify({a:"a", b:"b", c:"c", 3: "d", 2: "e", 1: "f"}, replaceFunc);
380        return replaceTracker;
381    }
382PASS tests[i](nativeJSON) is tests[i].expected
383function (jsonObject){
384        var count = 0;
385        var array = [{toString:function(){count++; array[0]='a'; array[1]='c'; array[2]='b'; return 'a'}}];
386        jsonObject.stringify(simpleObject, array);
387        return count;
388    }
389PASS tests[i](nativeJSON) is tests[i](JSON)
390function (jsonObject){
391        var allString = true;
392        var array = [{toString:function(){array[0]='a'; array[1]='c'; array[2]='b'; return 'a'}}, 'b', 'c'];
393        return jsonObject.stringify(simpleObject, array);
394    }
395PASS tests[i](nativeJSON) is tests[i](JSON)
396function (jsonObject){
397        var count = 0;
398        var array = [{toString:function(){count++; array[0]='a'; array[1]='c'; array[2]='b'; return 'a'}}, 'b', 'c'];
399        jsonObject.stringify(simpleObject, array);
400        return count;
401    }
402PASS tests[i](nativeJSON) is tests[i](JSON)
403function (jsonObject){
404        return jsonObject.stringify({a:"1", get b() { this.a="foo"; return "getter"; }, c:"3"});
405    }
406PASS tests[i](nativeJSON) is tests[i](JSON)
407function (jsonObject){
408        return jsonObject.stringify({a:"1", get b() { this.c="foo"; return "getter"; }, c:"3"});
409    }
410PASS tests[i](nativeJSON) is tests[i](JSON)
411function (jsonObject){
412        var setterCalled = false;
413        jsonObject.stringify({a:"1", set b(s) { setterCalled = true; return "setter"; }, c:"3"});
414        return setterCalled;
415    }
416PASS tests[i](nativeJSON) is tests[i](JSON)
417function (jsonObject){
418        return jsonObject.stringify({a:"1", get b(){ return "getter"; }, set b(s) { return "setter"; }, c:"3"});
419    }
420PASS tests[i](nativeJSON) is tests[i](JSON)
421function (jsonObject){
422        return jsonObject.stringify(new Array(10));
423    }
424PASS tests[i](nativeJSON) is tests[i](JSON)
425function (jsonObject){
426        return jsonObject.stringify([undefined,,null,0,false]);
427    }
428PASS tests[i](nativeJSON) is tests[i](JSON)
429function (jsonObject){
430        return jsonObject.stringify({p1:undefined,p2:null,p3:0,p4:false});
431    }
432PASS tests[i](nativeJSON) is tests[i](JSON)
433function (jsonObject){
434        cycleTracker = "";
435        return jsonObject.stringify(cyclicObject);
436    }
437PASS tests[i](nativeJSON) threw exception TypeError: Converting circular structure to JSON.
438function (jsonObject){
439        cycleTracker = "";
440        try { jsonObject.stringify(cyclicObject); } catch(e) { cycleTracker += " -> exception" }
441        return cycleTracker;
442    }
443PASS tests[i](nativeJSON) is tests[i].expected
444function (jsonObject){
445        cycleTracker = "";
446        return jsonObject.stringify(cyclicArray);
447    }
448PASS tests[i](nativeJSON) threw exception TypeError: Converting circular structure to JSON.
449function (jsonObject){
450        cycleTracker = "";
451        try { jsonObject.stringify(cyclicArray); } catch(e) { cycleTracker += " -> exception" }
452        return cycleTracker;
453    }
454FAIL tests[i](nativeJSON) should be 0(number):[object Object]first, -> exception. Was 0(string):[object Object]first, -> exception.
455function (jsonObject){
456        getterCalls = 0;
457        return jsonObject.stringify(magicObject) + " :: getter calls = " + getterCalls;
458    }
459PASS tests[i](nativeJSON) is tests[i](JSON)
460function (jsonObject){
461        return jsonObject.stringify(undefined);
462    }
463PASS tests[i](nativeJSON) is tests[i](JSON)
464function (jsonObject){
465        return jsonObject.stringify(null);
466    }
467PASS tests[i](nativeJSON) is tests[i](JSON)
468function (jsonObject){
469        return jsonObject.stringify({toJSON:function(){ return undefined; }});
470    }
471PASS tests[i](nativeJSON) is tests[i](JSON)
472function (jsonObject){
473        return jsonObject.stringify({toJSON:function(){ return null; }});
474    }
475PASS tests[i](nativeJSON) is tests[i](JSON)
476function (jsonObject){
477        return jsonObject.stringify([{toJSON:function(){ return undefined; }}]);
478    }
479PASS tests[i](nativeJSON) is tests[i](JSON)
480function (jsonObject){
481        return jsonObject.stringify([{toJSON:function(){ return null; }}]);
482    }
483PASS tests[i](nativeJSON) is tests[i](JSON)
484function (jsonObject){
485        return jsonObject.stringify({a:{toJSON:function(){ return undefined; }}});
486    }
487PASS tests[i](nativeJSON) is tests[i](JSON)
488function (jsonObject){
489        return jsonObject.stringify({a:{toJSON:function(){ return null; }}});
490    }
491PASS tests[i](nativeJSON) is tests[i](JSON)
492function (jsonObject){
493        return jsonObject.stringify({a:{toJSON:function(){ return function(){}; }}});
494    }
495PASS tests[i](nativeJSON) is tests[i](JSON)
496function (jsonObject){
497        return jsonObject.stringify({a:function(){}});
498    }
499PASS tests[i](nativeJSON) is tests[i](JSON)
500function (jsonObject){
501        var deepObject = {};
502        for (var i = 0; i < 1024; i++)
503            deepObject = {next:deepObject};
504        return jsonObject.stringify(deepObject);
505    }
506PASS tests[i](nativeJSON) is tests[i](JSON)
507function (jsonObject){
508        var deepArray = [];
509        for (var i = 0; i < 1024; i++)
510            deepArray = [deepArray];
511        return jsonObject.stringify(deepArray);
512    }
513PASS tests[i](nativeJSON) is tests[i](JSON)
514function (jsonObject){
515        var depth = 0;
516        function toDeepVirtualJSONObject() {
517            if (++depth >= 1024)
518                return {};
519            var r = {};
520            r.toJSON = toDeepVirtualJSONObject;
521            return {recurse: r};
522        }
523        return jsonObject.stringify(toDeepVirtualJSONObject());
524    }
525PASS tests[i](nativeJSON) is tests[i](JSON)
526function (jsonObject){
527        var depth = 0;
528        function toDeepVirtualJSONArray() {
529            if (++depth >= 1024)
530                return [];
531            var r = [];
532            r.toJSON = toDeepJSONArray;
533            return [r];
534        }
535        return jsonObject.stringify(toDeepVirtualJSONArray());
536    }
537function (jsonObject){
538        return jsonObject.stringify(fullCharsetString);
539    }
540PASS tests[i](nativeJSON) is tests[i](JSON)
541PASS successfullyParsed is true
542
543TEST COMPLETE
544
545