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

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

Issue 1850663002: Add parsing for class declarations (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@types-1839393002-aliases
Patch Set: Created 4 years, 9 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 16ce3f71d432fdcb96368769a35b3bbb12c0ef01..bc04b436d2ef5a15dce4280f693b7bf900823941 100644
--- a/test/cctest/test-parsing.cc
+++ b/test/cctest/test-parsing.cc
@@ -7867,3 +7867,46 @@ TEST(TypedModeTypeAliases) {
RunParserSyncTest(typed_context_data, error_data, kError, NULL, 0,
always_flags, arraysize(always_flags));
}
+
+TEST(TypedModeClassDeclarations) {
+ const char* untyped_context_data[][2] = {{"", ""}, {NULL, NULL}};
+ const char* typed_context_data[][2] = {{"'use types'; ", ""}, {NULL, NULL}};
+
+ const char* correct_data[] = {
+ "class C { f(x: number) : boolean { return x == 42; } }",
+ "class D extends C { g<A>(x: A[]) : A { return x[0]; } }",
+ "class E extends D implements I, J {}",
+ "class F<A> extends D implements I<A>, J<number, A> {}",
+ "class C { x; y=42; z: number; w: number = 17; }",
+ "class C { [x: string]; }",
+ "class C { [x: number]; }",
+ "class C { [x: string] : boolean; }",
+ "class C { [x: number] : boolean; }",
+ NULL
+ };
+
+ const char* error_data[] = {
+ "class C { f(x: number) : () {} }",
+ "class D implements () {}",
+ "class E implements number[] {}",
+ "class F implements I<> {}",
rossberg 2016/04/18 11:03:08 class implements {} class C implements {} class im
nickie 2016/04/19 14:55:30 Done.
+ "class E<> {}",
+ "class C { x: (); }",
+ "class C { [42]; }",
+ "class C { [42] : number; }",
+ "class C { [x: any]; }",
+ "class C { [x: any] : any; }",
+ "class C { static [x: number]; }",
+ NULL
+ };
+
+ static const ParserFlag always_flags[] = {kAllowTypes};
+ RunParserSyncTest(untyped_context_data, correct_data, kError, NULL, 0,
+ always_flags, arraysize(always_flags));
+ RunParserSyncTest(typed_context_data, correct_data, kSuccess, NULL, 0,
+ always_flags, arraysize(always_flags));
+ RunParserSyncTest(untyped_context_data, error_data, kError, NULL, 0,
+ always_flags, arraysize(always_flags));
+ RunParserSyncTest(typed_context_data, error_data, kError, NULL, 0,
+ always_flags, arraysize(always_flags));
+}

Powered by Google App Engine
This is Rietveld 408576698