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

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

Issue 2348783002: [AST] Add method to concatenate AstRawStrings (Closed)
Patch Set: use ConcatString Created 4 years, 3 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
Index: test/cctest/test-parsing.cc
diff --git a/test/cctest/test-parsing.cc b/test/cctest/test-parsing.cc
index bbfe7b53efccf6c4d6a88b207f8ed823abdeb7b1..376cc9b9e9afca23b366671121d718a7c5f62076 100644
--- a/test/cctest/test-parsing.cc
+++ b/test/cctest/test-parsing.cc
@@ -1491,6 +1491,7 @@ enum ParserFlag {
kAllowHarmonyRestrictiveGenerators,
kAllowHarmonyTrailingCommas,
kAllowHarmonyClassFields,
+ kAllowHarmonyPrivateClassFields,
};
enum ParserSyncTestResult {
@@ -1517,6 +1518,8 @@ void SetParserFlags(i::ParserBase<Traits>* parser,
flags.Contains(kAllowHarmonyTrailingCommas));
parser->set_allow_harmony_class_fields(
flags.Contains(kAllowHarmonyClassFields));
+ parser->set_allow_harmony_private_class_fields(
+ flags.Contains(kAllowHarmonyPrivateClassFields));
}
@@ -4727,6 +4730,102 @@ TEST(ClassFieldsErrors) {
arraysize(with_async));
}
+TEST(ClassPrivatesNoErrors) {
+ // clang-format off
+ // Tests proposed class private fields syntax.
+ const char* class_body_contexts[][2] = {{"(class {", "});"},
+ {"(class extends Base {", "});"},
+ {"class C {", "}"},
+ {"class C extends Base {", "}"},
+ {NULL, NULL}};
+ const char* class_body_data[] = {
+ // Basic syntax
+ "#a = 0;",
+ "#a = 0; #b",
+ "#a = 0; b(){}",
+ "#a = 0; *b(){}",
+ "#a = 0; ['b'](){}",
+ "#a;",
+ "#a; #b;",
+ "#a; b(){}",
+ "#a; *b(){}",
+ "#a; ['b'](){}",
+
+ // ASI
+ "#a = 0\n",
+ "#a = 0\n #b",
+ "#a = 0\n b(){}",
+ "#a\n",
+ "#a\n #b\n",
+ "#a\n b(){}",
+ "#a\n *b(){}",
+ "#a\n ['b'](){}",
+
+ // Misc edge cases
+ "#yield",
+ "#yield = 0",
+ "#yield\n #a",
+ NULL
+ };
+ // clang-format on
+
+ static const ParserFlag flags[] = {kAllowHarmonyPrivateClassFields};
+ RunParserSyncTest(class_body_contexts, class_body_data, kSuccess, NULL, 0,
+ flags, arraysize(flags));
+
+ // clang-format off
+ const char* declaration_contexts[][2] = {{"(class { #x;", "});"},
+ {"(class extends Base { #x;", "});"},
+ {"class C { #x;", "}"},
+ {"class C extends Base { #x;", "}"},
+ {"(class {", "\n#x;});"},
+ {NULL, NULL}};
+ const char* declaration_bodies[] = {
+ "m(){ ++#x; return #x; }",
+ "m(o){ ++#x; return o.#x; }",
+ "m(){ #x = 0; }",
+ "m(o){ o.#x = 0; }",
+ "m(){ ({a: #x} = {a: 0}); }",
+ "m(){ ({a: o.#x} = {a: 0}); }",
+ "static m(){ ++#x; return #x; }",
+ "static m(o){ ++#x; return o.#x; }",
+ "static m(){ #x = 0; }",
+ "static m(o){ o.#x = 0; }",
+ "static m(){ ({a: #x} = {a: 0}); }",
+ "static m(){ ({a: o.#x} = {a: 0}); }",
+ NULL
+ };
+ // clang-format on
+
+ RunParserSyncTest(declaration_contexts, declaration_bodies, kSuccess, NULL, 0,
+ flags, arraysize(flags));
+}
+
+TEST(ClassPrivatesErrors) {
+ // clang-format off
+ // Tests proposed class private fields syntax.
+ const char* context_data[][2] = {{"(class {", "});"},
+ {"(class extends Base {", "});"},
+ {"class C {", "}"},
+ {"class C extends Base {", "}"},
+ {NULL, NULL}};
+ // clang-format off
+ const char* class_body_data[] = {
+ "#x = 0\n *a(){}",
+ "#['x'] = 0;",
+ "#['x'];",
+ "#x; #x;",
+ "#x = 0; #x;",
+ "#x = 0; #x = 0",
+ NULL
+ };
+ // clang-format on
+
+ static const ParserFlag without_async[] = {kAllowHarmonyPrivateClassFields};
+ RunParserSyncTest(context_data, class_body_data, kError, NULL, 0,
+ without_async, arraysize(without_async));
+}
+
TEST(ClassExpressionErrors) {
const char* context_data[][2] = {{"(", ");"},
{"var C = ", ";"},
« no previous file with comments | « test/cctest/interpreter/bytecode_expectations/Generators.golden ('k') | test/mjsunit/harmony/class-privates-delete.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698