OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 assertEquals("[\n^1,\n^2,\n^3\n]", JSON.stringify([1, 2, 3], null, "^")); | 249 assertEquals("[\n^1,\n^2,\n^3\n]", JSON.stringify([1, 2, 3], null, "^")); |
250 assertEquals("[\n^1,\n^2,\n^3\n]", | 250 assertEquals("[\n^1,\n^2,\n^3\n]", |
251 JSON.stringify([1, 2, 3], null, new String("^"))); | 251 JSON.stringify([1, 2, 3], null, new String("^"))); |
252 assertEquals("[\n 1,\n 2,\n [\n 3,\n [\n 4\n ],\n 5\n ],\n 6,\n 7\n]", | 252 assertEquals("[\n 1,\n 2,\n [\n 3,\n [\n 4\n ],\n 5\n ],\n 6,\n 7\n]", |
253 JSON.stringify([1, 2, [3, [4], 5], 6, 7], null, 1)); | 253 JSON.stringify([1, 2, [3, [4], 5], 6, 7], null, 1)); |
254 assertEquals("[]", JSON.stringify([], null, 1)); | 254 assertEquals("[]", JSON.stringify([], null, 1)); |
255 assertEquals("[1,2,[3,[4],5],6,7]", | 255 assertEquals("[1,2,[3,[4],5],6,7]", |
256 JSON.stringify([1, 2, [3, [4], 5], 6, 7], null)); | 256 JSON.stringify([1, 2, [3, [4], 5], 6, 7], null)); |
257 assertEquals("[2,4,[6,[8],10],12,14]", | 257 assertEquals("[2,4,[6,[8],10],12,14]", |
258 JSON.stringify([1, 2, [3, [4], 5], 6, 7], DoubleNumbers)); | 258 JSON.stringify([1, 2, [3, [4], 5], 6, 7], DoubleNumbers)); |
| 259 assertEquals('["a","ab","abc"]', JSON.stringify(["a","ab","abc"])); |
259 | 260 |
260 var circular = [1, 2, 3]; | 261 var circular = [1, 2, 3]; |
261 circular[2] = circular; | 262 circular[2] = circular; |
262 assertThrows(function () { JSON.stringify(circular); }, TypeError); | 263 assertThrows(function () { JSON.stringify(circular); }, TypeError); |
263 | 264 |
264 var singleton = []; | 265 var singleton = []; |
265 var multiOccurrence = [singleton, singleton, singleton]; | 266 var multiOccurrence = [singleton, singleton, singleton]; |
266 assertEquals("[[],[],[]]", JSON.stringify(multiOccurrence)); | 267 assertEquals("[[],[],[]]", JSON.stringify(multiOccurrence)); |
267 | 268 |
268 assertEquals('{"x":5,"y":6}', JSON.stringify({x:5,y:6})); | 269 assertEquals('{"x":5,"y":6}', JSON.stringify({x:5,y:6})); |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 // | 423 // |
423 // Parse a non-object value as __proto__. This must not create a | 424 // Parse a non-object value as __proto__. This must not create a |
424 // __proto__ property different from the original, and should not | 425 // __proto__ property different from the original, and should not |
425 // change the original. | 426 // change the original. |
426 var o = JSON.parse('{"__proto__":5}'); | 427 var o = JSON.parse('{"__proto__":5}'); |
427 assertEquals(Object.prototype, o.__proto__); // __proto__ isn't changed. | 428 assertEquals(Object.prototype, o.__proto__); // __proto__ isn't changed. |
428 assertEquals(0, Object.keys(o).length); // __proto__ isn't added as enumerable. | 429 assertEquals(0, Object.keys(o).length); // __proto__ isn't added as enumerable. |
429 | 430 |
430 | 431 |
431 | 432 |
OLD | NEW |