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

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

Issue 1817353003: Add tests for variable declarations (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@types
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
« no previous file with comments | « no previous file | test/mjsunit/harmony/typesystem/object-types.js » ('j') | 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 0e7daf258714dd88bee0b6a35b0bbfbdd5acc11f..e50eb0db7a1d55fe124e42868b28732d9b3ab7e4 100644
--- a/test/cctest/test-parsing.cc
+++ b/test/cctest/test-parsing.cc
@@ -7451,13 +7451,51 @@ TEST(TypedVariableDeclarations) {
const char* typed_context_data[][2] = {{"'use types'; ", ""}, {NULL, NULL}};
const char* untyped_data[] = {
- "var x = 42",
NULL
};
const char* typed_data[] = {
"var x: number = 42",
"var s: string = 'hello world'",
+ "var x : any",
+ "let x : any",
+ "var x : any = undefined",
+ "let x : any = undefined",
+ "const x : any = undefined",
+ "var [x, y, ...rest] : any[] = []",
+ "let [x, y, ...rest] : any[] = []",
+ "const [x, y, ...rest] : any[] = []",
+ "var [x,, z] : [any] = [undefined,, undefined]",
+ "let [x,, z] : [any] = [undefined,, undefined]",
+ "const [x,, z] : [any] = [undefined,, undefined]",
+ "var {a: x, b: y} : {a: number, b: string} = {a: 17, b: 'hello'}",
+ "let {a: x, b: y} : {a: number, b: string} = {a: 17, b: 'hello'}",
+ "const {a: x, b: y} : {a: number, b: string} = {a: 17, b: 'hello'}",
+ NULL
+ };
+
+ const char* typed_error_data[] = {
+ "var x : ()",
+ "let x : ()",
+ "var x : () = undefined",
+ "let x : () = undefined",
+ "const x : () = undefined",
+ "var [x, y, ...rest] : ()[]",
+ "let [x, y, ...rest] : ()[]",
+ "const [x, y, ...rest] : ()[] = []",
+ "var [x,, z] : [any, (), any]",
+ "let [x,, z] : [any, (), any]",
+ "const [x,, z] : [any, (), any] = [1, 2, 3]",
+ "var {a: x, b: y} : {a: (), b: number}",
+ "let {a: x, b: y} : {a: (), b: number}",
+ "const {a: x, b: y} : {a: (), b: number} = {a: 17, b: 42}",
+ "var [x, y]: number[];",
+ "var {a: x, b: y}: {a: number, b: string};",
+ "let [x, y]: number[];",
+ "let {a: x, b: y}: {a: number, b: string};",
+ "const x: number;",
+ "const [x, y]: [number, string];",
+ "const {a: x, b: y}: {a: number, b: string};",
NULL
};
@@ -7470,6 +7508,10 @@ TEST(TypedVariableDeclarations) {
always_flags, arraysize(always_flags));
RunParserSyncTest(typed_context_data, typed_data, kSuccess, NULL, 0,
always_flags, arraysize(always_flags));
+ RunParserSyncTest(untyped_context_data, typed_error_data, kError, NULL, 0,
+ always_flags, arraysize(always_flags));
+ RunParserSyncTest(typed_context_data, typed_error_data, kError, NULL, 0,
+ always_flags, arraysize(always_flags));
}
TEST(TypedModeChecks) {
« no previous file with comments | « no previous file | test/mjsunit/harmony/typesystem/object-types.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698