Index: test/cctest/test-parsing.cc |
diff --git a/test/cctest/test-parsing.cc b/test/cctest/test-parsing.cc |
index e45e9ebb892c7499b6808296eb6166b00c4ed58d..cb46b5a113e5ce4e2b6c1306c18b99c4cb5a1c9d 100644 |
--- a/test/cctest/test-parsing.cc |
+++ b/test/cctest/test-parsing.cc |
@@ -1814,6 +1814,33 @@ TEST(NoErrorsEvalAndArgumentsStrict) { |
} |
+#define FUTURE_STRICT_RESERVED_WORDS(V) \ |
+ V(implements) \ |
+ V(interface) \ |
+ V(let) \ |
+ V(package) \ |
+ V(private) \ |
+ V(protected) \ |
+ V(public) \ |
+ V(static) \ |
+ V(yield) |
+ |
+ |
+#define FUTURE_STRICT_RESERVED_STATEMENTS(NAME) \ |
+ "var " #NAME ";", \ |
+ "var foo, " #NAME ";", \ |
+ "try { } catch (" #NAME ") { }", \ |
+ "function " #NAME "() { }", \ |
+ "(function " #NAME "() { })", \ |
+ "function foo(" #NAME ") { }", \ |
+ "function foo(bar, " #NAME ") { }", \ |
+ #NAME " = 1;", \ |
+ #NAME " += 1;", \ |
+ "var foo = " #NAME " = 1;", \ |
+ "++" #NAME ";", \ |
+ #NAME " ++;", |
+ |
+ |
TEST(ErrorsFutureStrictReservedWords) { |
// Tests that both preparsing and parsing produce the right kind of errors for |
// using future strict reserved words as identifiers. Without the strict mode, |
@@ -1826,24 +1853,19 @@ TEST(ErrorsFutureStrictReservedWords) { |
{ NULL, NULL } |
}; |
- const char* statement_data[] = { |
- "var interface;", |
- "var foo, interface;", |
- "try { } catch (interface) { }", |
- "function interface() { }", |
- "function foo(interface) { }", |
- "function foo(bar, interface) { }", |
- "interface = 1;", |
- "var foo = interface = 1;", |
- "++interface;", |
- "interface++;", |
- "var yield = 13;", |
+ const char* statement_data[] { |
+ FUTURE_STRICT_RESERVED_WORDS(FUTURE_STRICT_RESERVED_STATEMENTS) |
NULL |
}; |
static const ParserFlag always_flags[] = {kAllowArrowFunctions}; |
RunParserSyncTest(context_data, statement_data, kError, NULL, 0, always_flags, |
arraysize(always_flags)); |
+ |
+ static const ParserFlag classes_flags[] = { |
+ kAllowArrowFunctions, kAllowClasses, kAllowHarmonyScoping}; |
+ RunParserSyncTest(context_data, statement_data, kError, NULL, 0, |
+ classes_flags, arraysize(classes_flags)); |
} |
@@ -1856,23 +1878,18 @@ TEST(NoErrorsFutureStrictReservedWords) { |
}; |
const char* statement_data[] = { |
- "var interface;", |
- "var foo, interface;", |
- "try { } catch (interface) { }", |
- "function interface() { }", |
- "function foo(interface) { }", |
- "function foo(bar, interface) { }", |
- "interface = 1;", |
- "var foo = interface = 1;", |
- "++interface;", |
- "interface++;", |
- "var yield = 13;", |
+ FUTURE_STRICT_RESERVED_WORDS(FUTURE_STRICT_RESERVED_STATEMENTS) |
NULL |
}; |
static const ParserFlag always_flags[] = {kAllowArrowFunctions}; |
RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0, |
always_flags, arraysize(always_flags)); |
+ |
+ static const ParserFlag classes_flags[] = { |
+ kAllowArrowFunctions, kAllowClasses, kAllowHarmonyScoping}; |
+ RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0, |
+ classes_flags, arraysize(classes_flags)); |
} |
@@ -2252,12 +2269,13 @@ TEST(ErrorsIllegalWordsAsLabelsStrict) { |
{ NULL, NULL } |
}; |
+#define LABELLED_WHILE(NAME) #NAME ": while (true) { break " #NAME "; }", |
const char* statement_data[] = { |
"super: while(true) { break super; }", |
- "interface: while(true) { break interface; }", |
- "yield: while(true) { break yield; }", |
+ FUTURE_STRICT_RESERVED_WORDS(LABELLED_WHILE) |
NULL |
}; |
+#undef LABELLED_WHILE |
RunParserSyncTest(context_data, statement_data, kError); |
} |
@@ -2288,6 +2306,27 @@ TEST(NoErrorsIllegalWordsAsLabels) { |
} |
+TEST(NoErrorsFutureStrictReservedAsLabelsSloppy) { |
+ const char* context_data[][2] = { |
+ { "", ""}, |
+ { "function test_func() {", "}" }, |
+ { "() => {", "}" }, |
+ { NULL, NULL } |
+ }; |
+ |
+#define LABELLED_WHILE(NAME) #NAME ": while (true) { break " #NAME "; }", |
+ const char* statement_data[] { |
+ FUTURE_STRICT_RESERVED_WORDS(LABELLED_WHILE) |
+ NULL |
+ }; |
+#undef LABELLED_WHILE |
+ |
+ static const ParserFlag always_flags[] = {kAllowArrowFunctions}; |
+ RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0, |
+ always_flags, arraysize(always_flags)); |
+} |
+ |
+ |
TEST(ErrorsParenthesizedLabels) { |
// Parenthesized identifiers shouldn't be recognized as labels. |
const char* context_data[][2] = { |