Chromium Code Reviews| 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 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 310 | 310 |
| 311 TestInvalid('1); throw "foo"; (1'); | 311 TestInvalid('1); throw "foo"; (1'); |
| 312 | 312 |
| 313 var x = 0; | 313 var x = 0; |
| 314 eval("(1); x++; (1)"); | 314 eval("(1); x++; (1)"); |
| 315 TestInvalid('1); x++; (1'); | 315 TestInvalid('1); x++; (1'); |
| 316 | 316 |
| 317 // Test string conversion of argument. | 317 // Test string conversion of argument. |
| 318 var o = { toString: function() { return "42"; } }; | 318 var o = { toString: function() { return "42"; } }; |
| 319 assertEquals(42, JSON.parse(o)); | 319 assertEquals(42, JSON.parse(o)); |
| 320 | |
| 321 | |
| 322 for (var i = 0; i < 65536; i++) { | |
| 323 var string = String.fromCharCode(i); | |
| 324 var encoded = JSON.stringify(string); | |
| 325 var expected = "uninitialized"; | |
| 326 // Following the ES5 specification of the abstraction function Quote. | |
| 327 if (string == '"' || string == '\\') { | |
| 328 // Step 2.a | |
| 329 expected = '\\' + string; | |
| 330 } else if ("\b\t\n\r\f".indexOf(string) >= 0) { | |
| 331 // Step 2.b | |
| 332 if (string == '\b') expected = '\\b'; | |
| 333 else if (string == '\t') expected = '\\t'; | |
| 334 else if (string == '\n') expected = '\\n'; | |
| 335 else if (string == '\f') expected = '\\f'; | |
| 336 else if (string == '\r') expected = '\\r'; | |
| 337 } else if (i < 32) { | |
| 338 // Step 2.c | |
| 339 if (i < 16) { | |
| 340 expected = "\\u000" + i.toString(16); | |
|
Rico
2010/09/01 14:48:20
Indention off
| |
| 341 } else { | |
| 342 expected = "\\u00" + i.toString(16); | |
|
Rico
2010/09/01 14:48:20
Indention off
| |
| 343 } | |
| 344 } else { | |
| 345 expected = string; | |
| 346 } | |
| 347 assertEquals('"' + expected + '"', encoded, "Codepoint " + i); | |
| 348 } | |
| OLD | NEW |