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

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

Issue 480543002: Parse 'super' keyword. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Patch for landing (minor fix for tests in release mode) Created 6 years, 4 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
« no previous file with comments | « src/typing.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 9cb5d69e6c5c1849465a769c2205451cdc7f2421..b905afb95492a9fc53463fbcb4f988d5e6809dfa 100644
--- a/test/cctest/test-parsing.cc
+++ b/test/cctest/test-parsing.cc
@@ -72,6 +72,7 @@ TEST(ScanKeywords) {
// The scanner should parse Harmony keywords for this test.
scanner.SetHarmonyScoping(true);
scanner.SetHarmonyModules(true);
+ scanner.SetHarmonyClasses(true);
scanner.Initialize(&stream);
CHECK_EQ(key_token.token, scanner.Next());
CHECK_EQ(i::Token::EOS, scanner.Next());
@@ -1209,7 +1210,8 @@ enum ParserFlag {
kAllowModules,
kAllowGenerators,
kAllowHarmonyNumericLiterals,
- kAllowArrowFunctions
+ kAllowArrowFunctions,
+ kAllowClasses
};
@@ -1230,6 +1232,7 @@ void SetParserFlags(i::ParserBase<Traits>* parser,
parser->set_allow_harmony_numeric_literals(
flags.Contains(kAllowHarmonyNumericLiterals));
parser->set_allow_arrow_functions(flags.Contains(kAllowArrowFunctions));
+ parser->set_allow_classes(flags.Contains(kAllowClasses));
}
@@ -1512,7 +1515,8 @@ void RunParserSyncTest(const char* context_data[][2],
static const ParserFlag default_flags[] = {
kAllowLazy, kAllowHarmonyScoping, kAllowModules,
- kAllowGenerators, kAllowNativesSyntax, kAllowArrowFunctions};
+ kAllowGenerators, kAllowNativesSyntax, kAllowArrowFunctions,
+ kAllowClasses};
ParserFlag* generated_flags = NULL;
if (flags == NULL) {
flags = default_flags;
@@ -3343,3 +3347,47 @@ TEST(NoErrorsArrowFunctions) {
RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0,
always_flags, ARRAY_SIZE(always_flags));
}
+
+
+TEST(NoErrorsSuper) {
+ // Tests that parser and preparser accept 'super' keyword in right places.
+ const char* context_data[][2] = {{"", ";"},
+ {"k = ", ";"},
+ {"foo(", ");"},
+ {NULL, NULL}};
+
+ const char* statement_data[] = {
+ "super.x",
+ "super[27]",
+ "new super",
+ "new super()",
+ "new super(12, 45)",
+ "new new super",
+ "new new super()",
+ "new new super()()",
+ "z.super", // Ok, property lookup.
+ NULL};
+
+ static const ParserFlag always_flags[] = {kAllowClasses};
+ RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0,
+ always_flags, ARRAY_SIZE(always_flags));
+}
+
+
+TEST(ErrorsSuper) {
+ // Tests that parser and preparser generate same errors for 'super'.
+ const char* context_data[][2] = {{"", ";"},
+ {"k = ", ";"},
+ {"foo(", ");"},
+ {NULL, NULL}};
+
+ const char* statement_data[] = {
+ "super = x",
+ "y = super",
+ "f(super)",
+ NULL};
+
+ static const ParserFlag always_flags[] = {kAllowClasses};
+ RunParserSyncTest(context_data, statement_data, kError, NULL, 0,
+ always_flags, ARRAY_SIZE(always_flags));
+}
« no previous file with comments | « src/typing.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698