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// Unicode escapes in variable names.
8
9(function TestVariableNames1() {
10  var foobar = 1;
11  assertEquals(foob\u0061r, 1);
12  assertEquals(foob\u{0061}r, 1);
13  assertEquals(foob\u{61}r, 1);
14  assertEquals(foob\u{0000000061}r, 1);
15})();
16
17(function TestVariableNames2() {
18  var foobar = 1;
19  assertEquals(\u0066oobar, 1);
20  assertEquals(\u{0066}oobar, 1);
21  assertEquals(\u{66}oobar, 1);
22  assertEquals(\u{0000000066}oobar, 1);
23})();
24
25// Unicode escapes in strings.
26
27(function TestStrings() {
28  var s1 = "foob\u0061r";
29  assertEquals(s1, "foobar");
30  var s2 = "foob\u{0061}r";
31  assertEquals(s2, "foobar");
32  var s3 = "foob\u{61}r";
33  assertEquals(s3, "foobar");
34  var s4 = "foob\u{0000000061}r";
35  assertEquals(s4, "foobar");
36})();
37
38
39(function TestSurrogates() {
40  // U+10E6D corresponds to the surrogate pair [U+D803, U+DE6D].
41  var s1 = "foo\u{10e6d}";
42  var s2 = "foo\u{d803}\u{de6d}";
43  assertEquals(s1, s2);
44})();
45