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

Side by Side Diff: test/cctest/test-parsing.cc

Issue 1839393002: Add parsing for type aliases (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@types-1841093002-fun-decl
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « src/parsing/preparser.cc ('k') | test/mjsunit/harmony/typesystem/type-aliases.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 7819 matching lines...) Expand 10 before | Expand all | Expand 10 after
7830 static const ParserFlag always_flags[] = {kAllowTypes}; 7830 static const ParserFlag always_flags[] = {kAllowTypes};
7831 RunParserSyncTest(untyped_context_data, correct_data, kError, NULL, 0, 7831 RunParserSyncTest(untyped_context_data, correct_data, kError, NULL, 0,
7832 always_flags, arraysize(always_flags)); 7832 always_flags, arraysize(always_flags));
7833 RunParserSyncTest(typed_context_data, correct_data, kSuccess, NULL, 0, 7833 RunParserSyncTest(typed_context_data, correct_data, kSuccess, NULL, 0,
7834 always_flags, arraysize(always_flags)); 7834 always_flags, arraysize(always_flags));
7835 RunParserSyncTest(untyped_context_data, error_data, kError, NULL, 0, 7835 RunParserSyncTest(untyped_context_data, error_data, kError, NULL, 0,
7836 always_flags, arraysize(always_flags)); 7836 always_flags, arraysize(always_flags));
7837 RunParserSyncTest(typed_context_data, error_data, kError, NULL, 0, 7837 RunParserSyncTest(typed_context_data, error_data, kError, NULL, 0,
7838 always_flags, arraysize(always_flags)); 7838 always_flags, arraysize(always_flags));
7839 } 7839 }
7840
7841 TEST(TypedModeTypeAliases) {
7842 const char* untyped_context_data[][2] = {{"", ""}, {NULL, NULL}};
7843 const char* typed_context_data[][2] = {{"'use types'; ", ""}, {NULL, NULL}};
7844
7845 const char* correct_data[] = {
7846 "type NumArray = number[]",
7847 "type Fun = (x: number) => number",
7848 "type Tree<A> = A | Tree<A>[]",
7849 NULL
7850 };
7851
7852 const char* error_data[] = {
7853 "type Err<> = number",
rossberg 2016/04/18 09:27:43 How about "type", with no identifier following.
nickie 2016/04/19 13:52:51 Done. We agreed that "type = number" should parse
7854 "type Err",
7855 "type Err =",
7856 "type Err = ()",
7857 NULL
7858 };
7859
7860 static const ParserFlag always_flags[] = {kAllowTypes};
7861 RunParserSyncTest(untyped_context_data, correct_data, kError, NULL, 0,
7862 always_flags, arraysize(always_flags));
7863 RunParserSyncTest(typed_context_data, correct_data, kSuccess, NULL, 0,
7864 always_flags, arraysize(always_flags));
7865 RunParserSyncTest(untyped_context_data, error_data, kError, NULL, 0,
7866 always_flags, arraysize(always_flags));
7867 RunParserSyncTest(typed_context_data, error_data, kError, NULL, 0,
7868 always_flags, arraysize(always_flags));
7869 }
OLDNEW
« no previous file with comments | « src/parsing/preparser.cc ('k') | test/mjsunit/harmony/typesystem/type-aliases.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698