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

Unified Diff: test/cctest/test-parsing.cc

Issue 652743009: Classes: static should still be treated as a strict reserved word (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Use let and not eval. Add tests that covers this too Created 6 years, 2 months 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
« src/preparser.h ('K') | « src/scanner.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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] = {
« src/preparser.h ('K') | « src/scanner.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698