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

Unified 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 side-by-side diff with in-line comments
Download patch
« test/cctest/test-parsing.cc ('K') | « test/cctest/test-parsing.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/es6/unicode-escapes.js
diff --git a/test/mjsunit/es6/unicode-escapes.js b/test/mjsunit/es6/unicode-escapes.js
new file mode 100644
index 0000000000000000000000000000000000000000..f143333f843fe6b39a7588ad784f8c210697909e
--- /dev/null
+++ b/test/mjsunit/es6/unicode-escapes.js
@@ -0,0 +1,58 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// ES6 extends the \uxxxx escape and also allows \u{xxxx}.
+
+// Unicode escapes in variable names.
+
+function TestVariableNames1() {
arv (Not doing code reviews) 2014/11/07 16:23:20 Or (function TestVariableNames1() { ... })();
marja 2014/11/13 11:53:20 Done.
+ var foobar = 1;
+ assertEquals(foob\u0061r, 1);
+ assertEquals(foob\u{0061}r, 1);
+}
+TestVariableNames1();
+
+function TestVariableNames2() {
+ var foobar = 1;
+ assertEquals(\u0066oobar, 1);
+ assertEquals(\u{0066}oobar, 1);
+}
+TestVariableNames2();
+
+// Unicode escapes in strings.
+
+function TestStrings() {
+ var s1 = "foob\u0061r";
+ assertEquals(s1, "foobar");
+ 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.
+ assertEquals(s2, "foobar");
+}
+TestStrings();
+
+// Unicode escapes in regexp body. Note that no escapes are allowed in regexp
+// 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.
+
+function TestRegexp1() {
+ var r1 = /(\u0066|\u0062)oo/;
+ assertTrue(r1.test("foo"));
+ assertTrue(r1.test("boo"));
+ assertFalse(r1.test("moo"));
+ var r2 = /(\u{0066}|\u{0062})oo/;
+ assertTrue(r2.test("foo"));
+ assertTrue(r2.test("boo"));
+ assertFalse(r2.test("moo"));
+}
+TestRegexp1();
+
+function TestRegexp2() {
+ var r1 = /[\u0062-\u0066]oo/;
+ assertTrue(r1.test("foo"));
+ assertTrue(r1.test("boo"));
+ assertFalse(r1.test("moo"));
+ var r2 = /[\u{0062}-\u{0066}]oo/;
+ assertTrue(r2.test("foo"));
+ assertTrue(r2.test("boo"));
+ assertFalse(r2.test("moo"));
+}
+TestRegexp2();
« 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