Index: test/mjsunit/harmony/typesystem/type-aliases.js |
diff --git a/test/mjsunit/harmony/typesystem/type-aliases.js b/test/mjsunit/harmony/typesystem/type-aliases.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..dc5faa3f917362eb4bf48db48c5476ad73036d49 |
--- /dev/null |
+++ b/test/mjsunit/harmony/typesystem/type-aliases.js |
@@ -0,0 +1,51 @@ |
+// Copyright 2016 the V8 project authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+// Flags: --harmony-types |
+ |
+ |
+load("test/mjsunit/harmony/typesystem/typegen.js"); |
+ |
+ |
+// In all the following functions, the size parameter (positive integer) |
+// denotes how many test cases will be tried. The variable test_size |
+// controls execution time of this test. It should not be too high. |
+let test_size = 1000; |
+ |
+ |
+function ValidTypeAliases(size) { |
+ return Generate(size, [ |
+ new TestGen(1, ValidTypes, [ |
+ t => "type T = " + t, |
+ t => "type T<A> = " + t, |
+ t => "type T<A, B> = " + t, |
+ t => "type T<A extends {x: number}, B> = " + t |
+ ]) |
+ ]); |
+} |
+ |
+function InvalidTypeAliases(size) { |
+ return Generate(size, [ |
+ new TestGen(1, InvalidTypes, [ |
+ t => "type T = " + t, |
+ t => "type T<A> = " + t, |
+ t => "type T<A, B> = " + t, |
+ t => "type T<A extends {x: number}, B> = " + t |
+ ]), |
+ "type T<> = number", |
+ "type T", |
+ "type T =" |
+ ]); |
+} |
+ |
+(function TestTypeAliases(size) { |
+ Test(size, [ |
+ new TestGen(3, ValidTypeAliases, [CheckValid]), |
+ new TestGen(1, InvalidTypeAliases, [CheckInvalid]), |
+ ]); |
+ CheckValid("var type; type"); |
+ CheckValid("var type, number=10; type = number+1"); |
+ CheckValid("function type() {}; type(1, 2, 3)"); |
+ CheckValid("var type; type\n42"); |
+})(test_size); |