| OLD | NEW |
| (Empty) |
| 1 description( | |
| 2 "Test numeric escapes in string literals - https://bugs.webkit.org/show_bug.cgi?
id=51724" | |
| 3 ); | |
| 4 | |
| 5 function test(_stringLiteral, _nonStrictResult, _strictResult) | |
| 6 { | |
| 7 stringLiteral = '"' + _stringLiteral + '"'; | |
| 8 nonStrictResult = _nonStrictResult; | |
| 9 shouldBe("eval(stringLiteral)", "nonStrictResult"); | |
| 10 | |
| 11 stringLiteral = '"use strict"; ' + stringLiteral; | |
| 12 if (_strictResult) { | |
| 13 strictResult = _strictResult; | |
| 14 shouldBe("eval(stringLiteral)", "strictResult"); | |
| 15 } else | |
| 16 shouldThrow("eval(stringLiteral)"); | |
| 17 } | |
| 18 | |
| 19 // Tests for single digit octal and decimal escapes. | |
| 20 // In non-strict mode 0-7 are octal escapes, 8-9 are NonEscapeCharacters. | |
| 21 // In strict mode only "\0" is permitted. | |
| 22 test("\\0", "\x00", "\x00"); | |
| 23 test("\\1", "\x01"); | |
| 24 test("\\7", "\x07"); | |
| 25 test("\\8", "8"); | |
| 26 test("\\9", "9"); | |
| 27 | |
| 28 // Tests for multi-digit octal values outside strict mode; | |
| 29 // Octal literals may be 1-3 digits long. In strict more all multi-digit sequen
ces are illegal. | |
| 30 test("\\00", "\x00"); | |
| 31 test("\\000", "\x00"); | |
| 32 test("\\0000", "\x000"); | |
| 33 | |
| 34 test("\\01", "\x01"); | |
| 35 test("\\001", "\x01"); | |
| 36 test("\\0001", "\x001"); | |
| 37 | |
| 38 test("\\10", "\x08"); | |
| 39 test("\\100", "\x40"); | |
| 40 test("\\1000", "\x400"); | |
| 41 | |
| 42 test("\\19", "\x019"); | |
| 43 test("\\109", "\x089"); | |
| 44 test("\\1009", "\x409"); | |
| 45 | |
| 46 test("\\99", "99"); | |
| OLD | NEW |