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

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

Issue 1801633003: Add parsing for type queries (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
« src/parsing/parser-base.h ('K') | « src/parsing/preparser.h ('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-query.js
diff --git a/test/mjsunit/harmony/typesystem/type-query.js b/test/mjsunit/harmony/typesystem/type-query.js
new file mode 100644
index 0000000000000000000000000000000000000000..c8627ee0cc118c331977cf6b752d3a90b097b821
--- /dev/null
+++ b/test/mjsunit/harmony/typesystem/type-query.js
@@ -0,0 +1,45 @@
+// 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
+
+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);
+}
+
+function valid(type) {
+ CheckValid(type);
+ CheckValid(type + "[]");
+ CheckValid(type + " & any");
+ CheckValid(type + " | any");
+ CheckValid("(" + type + ")[]");
+ CheckValid("(a: " + type + ") => any");
+}
+
+function invalid(type) {
+ CheckInvalid(type);
+ CheckInvalid(type + "[]");
+ CheckInvalid(type + " & any");
+ CheckInvalid(type + " | any");
+ CheckInvalid("(" + type + ")[]");
+ CheckInvalid("(a: " + type + ") => any");
+}
+
+(function TestTypeQueries() {
+ valid("typeof x");
+ valid("typeof x.a");
+ valid("typeof x.something.something_else");
+ valid("typeof x.a.b.c.d.e.f.g.h.i.j.k.l");
+
+ invalid("typeof");
+ invalid("typeof x.");
+ invalid("typeof x.a.b.c.d.e.f.g.h.i.j.k.l.");
+ invalid("typeof x => any");
+})();
« src/parsing/parser-base.h ('K') | « src/parsing/preparser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698