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"); |
})(); |