Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(508)

Side by Side Diff: test/mjsunit/es6/unicode-escapes.js

Issue 706263002: Implement ES6 unicode escapes. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: . Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« test/cctest/test-parsing.cc ('K') | « test/cctest/test-parsing.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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{xxxx}.
6
7 // Unicode escapes in variable names.
8
9 function TestVariableNames1() {
arv (Not doing code reviews) 2014/11/07 16:23:20 Or (function TestVariableNames1() { ... })();
marja 2014/11/13 11:53:20 Done.
10 var foobar = 1;
11 assertEquals(foob\u0061r, 1);
12 assertEquals(foob\u{0061}r, 1);
13 }
14 TestVariableNames1();
15
16 function TestVariableNames2() {
17 var foobar = 1;
18 assertEquals(\u0066oobar, 1);
19 assertEquals(\u{0066}oobar, 1);
20 }
21 TestVariableNames2();
22
23 // Unicode escapes in strings.
24
25 function TestStrings() {
26 var s1 = "foob\u0061r";
27 assertEquals(s1, "foobar");
28 var s2 = "foob\u{0061}r";
arv (Not doing code reviews) 2014/11/07 16:23:20 var s2 = "foob\u{61}r";
marja 2014/11/13 11:53:20 Done.
29 assertEquals(s2, "foobar");
30 }
31 TestStrings();
32
33 // Unicode escapes in regexp body. Note that no escapes are allowed in regexp
34 // flags.
mathias 2014/11/07 16:37:57 `u{…}` escapes are only allowed in regular express
marja 2014/11/13 11:53:20 Regexp escapes will be added in a separate CL.
35
36 function TestRegexp1() {
37 var r1 = /(\u0066|\u0062)oo/;
38 assertTrue(r1.test("foo"));
39 assertTrue(r1.test("boo"));
40 assertFalse(r1.test("moo"));
41 var r2 = /(\u{0066}|\u{0062})oo/;
42 assertTrue(r2.test("foo"));
43 assertTrue(r2.test("boo"));
44 assertFalse(r2.test("moo"));
45 }
46 TestRegexp1();
47
48 function TestRegexp2() {
49 var r1 = /[\u0062-\u0066]oo/;
50 assertTrue(r1.test("foo"));
51 assertTrue(r1.test("boo"));
52 assertFalse(r1.test("moo"));
53 var r2 = /[\u{0062}-\u{0066}]oo/;
54 assertTrue(r2.test("foo"));
55 assertTrue(r2.test("boo"));
56 assertFalse(r2.test("moo"));
57 }
58 TestRegexp2();
OLDNEW
« test/cctest/test-parsing.cc ('K') | « test/cctest/test-parsing.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698