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

Side by Side 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 unified diff | Download patch
« src/parsing/parser-base.h ('K') | « src/parsing/preparser.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Flags: --harmony-types
6
7 function CheckValid(type) {
8 // print("V:", type);
9 assertDoesNotThrow("'use types'; var x: " + type + ";");
10 }
11
12 function CheckInvalid(type) {
13 // print("I:", type);
14 assertThrows("'use types'; var x: " + type + ";", SyntaxError);
15 }
16
17 function valid(type) {
18 CheckValid(type);
19 CheckValid(type + "[]");
20 CheckValid(type + " & any");
21 CheckValid(type + " | any");
22 CheckValid("(" + type + ")[]");
23 CheckValid("(a: " + type + ") => any");
24 }
25
26 function invalid(type) {
27 CheckInvalid(type);
28 CheckInvalid(type + "[]");
29 CheckInvalid(type + " & any");
30 CheckInvalid(type + " | any");
31 CheckInvalid("(" + type + ")[]");
32 CheckInvalid("(a: " + type + ") => any");
33 }
34
35 (function TestTypeQueries() {
36 valid("typeof x");
37 valid("typeof x.a");
38 valid("typeof x.something.something_else");
39 valid("typeof x.a.b.c.d.e.f.g.h.i.j.k.l");
40
41 invalid("typeof");
42 invalid("typeof x.");
43 invalid("typeof x.a.b.c.d.e.f.g.h.i.j.k.l.");
44 invalid("typeof x => any");
45 })();
OLDNEW
« 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