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 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 assertEquals("[[],[],[]]", JSON.stringify(multiOccurrence)); | 188 assertEquals("[[],[],[]]", JSON.stringify(multiOccurrence)); |
189 | 189 |
190 assertEquals('{"x":5,"y":6}', JSON.stringify({x:5,y:6})); | 190 assertEquals('{"x":5,"y":6}', JSON.stringify({x:5,y:6})); |
191 assertEquals('{"x":5}', JSON.stringify({x:5,y:6}, ['x'])); | 191 assertEquals('{"x":5}', JSON.stringify({x:5,y:6}, ['x'])); |
192 assertEquals('{\n "a": "b",\n "c": "d"\n}', | 192 assertEquals('{\n "a": "b",\n "c": "d"\n}', |
193 JSON.stringify({a:"b",c:"d"}, null, 1)); | 193 JSON.stringify({a:"b",c:"d"}, null, 1)); |
194 assertEquals('{"y":6,"x":5}', JSON.stringify({x:5,y:6}, ['y', 'x'])); | 194 assertEquals('{"y":6,"x":5}', JSON.stringify({x:5,y:6}, ['y', 'x'])); |
195 | 195 |
196 assertEquals(undefined, JSON.stringify(undefined)); | 196 assertEquals(undefined, JSON.stringify(undefined)); |
197 assertEquals(undefined, JSON.stringify(function () { })); | 197 assertEquals(undefined, JSON.stringify(function () { })); |
| 198 |
| 199 function checkIllegal(str) { |
| 200 assertThrows(function () { JSON.parse(str); }, SyntaxError); |
| 201 } |
| 202 |
| 203 checkIllegal('1); throw "foo"; (1'); |
| 204 |
| 205 var x = 0; |
| 206 eval("(1); x++; (1)"); |
| 207 checkIllegal('1); x++; (1'); |
OLD | NEW |