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

Unified Diff: test/mjsunit/harmony/typesystem/type-aliases.js

Issue 1839393002: Add parsing for type aliases (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@types-1841093002-fun-decl
Patch Set: More tests and allow type as an indentifier Created 4 years, 8 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/cctest/test-parsing.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « test/cctest/test-parsing.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698