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

Unified Diff: test/mjsunit/harmony/typesystem/string-literal-types.js

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 | « test/mjsunit/harmony/typesystem/simple-types.js ('k') | test/mjsunit/harmony/typesystem/testgen.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/harmony/typesystem/string-literal-types.js
diff --git a/test/mjsunit/harmony/typesystem/string-literal-types.js b/test/mjsunit/harmony/typesystem/string-literal-types.js
index 1c5598b31ab3d3523529d0df677b64effbc6201f..e333ea5a60e88da31c58e6ef4f552e349ec0b7f3 100644
--- a/test/mjsunit/harmony/typesystem/string-literal-types.js
+++ b/test/mjsunit/harmony/typesystem/string-literal-types.js
@@ -4,31 +4,25 @@
// Flags: --harmony-types
-function CheckValid(type) {
- // print("V:", type);
- assertDoesNotThrow("'use types'; var x: " + type + ";");
-}
-function CheckInvalid(type) {
- // print("I:", type);
- assertThrows("'use types'; var x: " + type + ";", SyntaxError);
-}
+load("test/mjsunit/harmony/typesystem/testgen.js");
+
(function TestStringLiteralTypes() {
// These are not really valid here.
// They should only be valid in function/constructor signatures.
- CheckValid("(cmd: 'add', x: number, y: number) => number");
- CheckValid('(cmd: "sum", a: number[]) => number');
- CheckValid("(x: number, cmd: 'one', ...rest) => any");
- CheckValid("(x: string, y: number, cmd: 'two', ...rest) => any");
- CheckValid("(x: number, cmd?: 'two', ...rest) => string");
+ CheckValidType("(cmd: 'add', x: number, y: number) => number");
+ CheckValidType('(cmd: "sum", a: number[]) => number');
+ CheckValidType("(x: number, cmd: 'one', ...rest) => any");
+ CheckValidType("(x: string, y: number, cmd: 'two', ...rest) => any");
+ CheckValidType("(x: number, cmd?: 'two', ...rest) => string");
// String literal types where they shouldn't be.
- CheckInvalid("'foo'");
- CheckInvalid("('foo')");
- CheckInvalid("'foo'[]");
- CheckInvalid("('foo')[]");
- CheckInvalid("('foo'[])");
- CheckInvalid("(('foo')[])");
- CheckInvalid("'foo' | 'bar'");
- CheckInvalid("('foo') => any");
+ CheckInvalidType("'foo'");
+ CheckInvalidType("('foo')");
+ CheckInvalidType("'foo'[]");
+ CheckInvalidType("('foo')[]");
+ CheckInvalidType("('foo'[])");
+ CheckInvalidType("(('foo')[])");
+ CheckInvalidType("'foo' | 'bar'");
+ CheckInvalidType("('foo') => any");
})();
« no previous file with comments | « test/mjsunit/harmony/typesystem/simple-types.js ('k') | test/mjsunit/harmony/typesystem/testgen.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698