OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // ES6 extends the \uxxxx escape and also allows \u{xxxxx}. |
| 6 |
| 7 // Flags: --harmony-unicode |
| 8 |
| 9 // Unicode escapes in variable names. |
| 10 |
| 11 (function TestVariableNames1() { |
| 12 var foobar = 1; |
| 13 assertEquals(foob\u0061r, 1); |
| 14 assertEquals(foob\u{0061}r, 1); |
| 15 assertEquals(foob\u{61}r, 1); |
| 16 assertEquals(foob\u{0000000061}r, 1); |
| 17 })(); |
| 18 |
| 19 (function TestVariableNames2() { |
| 20 var foobar = 1; |
| 21 assertEquals(\u0066oobar, 1); |
| 22 assertEquals(\u{0066}oobar, 1); |
| 23 assertEquals(\u{66}oobar, 1); |
| 24 assertEquals(\u{0000000066}oobar, 1); |
| 25 })(); |
| 26 |
| 27 // Unicode escapes in strings. |
| 28 |
| 29 (function TestStrings() { |
| 30 var s1 = "foob\u0061r"; |
| 31 assertEquals(s1, "foobar"); |
| 32 var s2 = "foob\u{0061}r"; |
| 33 assertEquals(s2, "foobar"); |
| 34 var s3 = "foob\u{61}r"; |
| 35 assertEquals(s3, "foobar"); |
| 36 var s4 = "foob\u{0000000061}r"; |
| 37 assertEquals(s4, "foobar"); |
| 38 })(); |
| 39 |
| 40 |
| 41 (function TestSurrogates() { |
| 42 // U+10E6D corresponds to the surrogate pair [U+D803, U+DE6D]. |
| 43 var s1 = "foo\u{10e6d}"; |
| 44 var s2 = "foo\u{d803}\u{de6d}"; |
| 45 assertEquals(s1, s2); |
| 46 })(); |
OLD | NEW |