Index: test/cctest/test-parsing.cc |
diff --git a/test/cctest/test-parsing.cc b/test/cctest/test-parsing.cc |
index 0ae46c33cad17f43e0bf2bb5176e83501eb09b7e..51bbc17697a8c2121e2f90bb4280d059a7eeea30 100644 |
--- a/test/cctest/test-parsing.cc |
+++ b/test/cctest/test-parsing.cc |
@@ -1344,7 +1344,8 @@ enum ParserFlag { |
kAllowHarmonyNumericLiterals, |
kAllowArrowFunctions, |
kAllowClasses, |
- kAllowHarmonyObjectLiterals |
+ kAllowHarmonyObjectLiterals, |
+ kAllowHarmonyUnicode |
}; |
@@ -1367,6 +1368,7 @@ void SetParserFlags(i::ParserBase<Traits>* parser, |
flags.Contains(kAllowHarmonyObjectLiterals)); |
parser->set_allow_arrow_functions(flags.Contains(kAllowArrowFunctions)); |
parser->set_allow_classes(flags.Contains(kAllowClasses)); |
+ parser->set_allow_harmony_unicode(flags.Contains(kAllowHarmonyUnicode)); |
} |
@@ -1663,6 +1665,7 @@ void RunParserSyncTest(const char* context_data[][2], |
kAllowHarmonyNumericLiterals, |
kAllowHarmonyObjectLiterals, |
kAllowHarmonyScoping, |
+ kAllowHarmonyUnicode, |
kAllowLazy, |
kAllowModules, |
kAllowNativesSyntax, |
@@ -4315,6 +4318,45 @@ TEST(InvalidUnicodeEscapes) { |
// No escapes allowed in regexp flags |
"/regex/\\u0069g", |
"/regex/\\u006g", |
+ // Braces gone wrong |
+ "var foob\\u{c481r = 0;", |
caitp (gmail)
2014/11/13 15:09:18
Might be worth adding a test for `var \\not-u` be
marja
2014/11/13 15:18:05
By var \not-u do you mean var \X where X is some l
marja
2014/12/02 10:26:20
Done.
|
+ "var foob\\uc481}r = 0;", |
+ "var \\u{0052oo = 0;", |
+ "var \\u0052}oo = 0;", |
+ "\"foob\\u{c481r\"", |
+ "var foob\\u{}ar = 0;", |
+ // Too high value for the unicode escape |
+ "\"\\u{110000}\"", |
NULL}; |
- RunParserSyncTest(context_data, data, kError); |
+ static const ParserFlag always_flags[] = {kAllowHarmonyUnicode}; |
+ RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, |
+ arraysize(always_flags)); |
+} |
+ |
+ |
+TEST(UnicodeEscapes) { |
+ const char* context_data[][2] = {{"", ""}, |
+ {"'use strict';", ""}, |
+ {NULL, NULL}}; |
+ const char* data[] = { |
+ // Identifier starting with escape |
+ "var \\u0052oo = 0;", |
+ "var \\u{0052}oo = 0;", |
+ "var \\u{52}oo = 0;", |
+ "var \\u{00000000052}oo = 0;", |
+ // Identifier with an escape but not starting with an escape |
+ "var foob\\uc481r = 0;", |
+ "var foob\\u{c481}r = 0;", |
+ // String with an escape |
+ "\"foob\\uc481r\"", |
+ "\"foob\\{uc481}r\"", |
+ // This character is a valid unicode character, representable as a surrogate |
+ // pair, not representable as 4 hex digits. |
+ "\"foo\\u{10e6d}\"", |
+ // Max value for the unicode escape |
+ "\"\\u{10ffff}\"", |
+ NULL}; |
+ static const ParserFlag always_flags[] = {kAllowHarmonyUnicode}; |
+ RunParserSyncTest(context_data, data, kSuccess, NULL, 0, always_flags, |
+ arraysize(always_flags)); |
} |