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

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

Issue 2258313002: [async functions] Disallow 'await' in arrow params inside async functions (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebased Created 4 years, 4 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/parser-base.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
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 7785 matching lines...) Expand 10 before | Expand all | Expand 10 after
7796 const char* body_data[] = { 7796 const char* body_data[] = {
7797 "var async = 1; return async;", 7797 "var async = 1; return async;",
7798 "let async = 1; return async;", 7798 "let async = 1; return async;",
7799 "const async = 1; return async;", 7799 "const async = 1; return async;",
7800 "function async() {} return async();", 7800 "function async() {} return async();",
7801 "var async = async => async; return async();", 7801 "var async = async => async; return async();",
7802 "function foo() { var await = 1; return await; }", 7802 "function foo() { var await = 1; return await; }",
7803 "function foo(await) { return await; }", 7803 "function foo(await) { return await; }",
7804 "function* foo() { var await = 1; return await; }", 7804 "function* foo() { var await = 1; return await; }",
7805 "function* foo(await) { return await; }", 7805 "function* foo(await) { return await; }",
7806 "var f = (await) => await;",
7807 "var f = () => { var await = 1; return await; }", 7806 "var f = () => { var await = 1; return await; }",
7808 "var O = { method() { var await = 1; return await; } };", 7807 "var O = { method() { var await = 1; return await; } };",
7809 "var O = { method(await) { return await; } };", 7808 "var O = { method(await) { return await; } };",
7810 "var O = { *method() { var await = 1; return await; } };", 7809 "var O = { *method() { var await = 1; return await; } };",
7811 "var O = { *method(await) { return await; } };", 7810 "var O = { *method(await) { return await; } };",
7812 7811
7813 "(function await() {})", 7812 "(function await() {})",
7814 NULL 7813 NULL
7815 }; 7814 };
7816 // clang-format on 7815 // clang-format on
(...skipping 11 matching lines...) Expand all
7828 { "", "" }, 7827 { "", "" },
7829 { NULL, NULL } 7828 { NULL, NULL }
7830 }; 7829 };
7831 7830
7832 const char* strict_context_data[][2] = { 7831 const char* strict_context_data[][2] = {
7833 { "'use strict';", "" }, 7832 { "'use strict';", "" },
7834 { NULL, NULL } 7833 { NULL, NULL }
7835 }; 7834 };
7836 7835
7837 const char* error_data[] = { 7836 const char* error_data[] = {
7838 "var asyncFn = async function() { var await = 1; };",
7839 "var asyncFn = async function() { var { await } = 1; };",
7840 "var asyncFn = async function() { var [ await ] = 1; };",
7841 "var asyncFn = async function await() {};", 7837 "var asyncFn = async function await() {};",
7842 "var asyncFn = async () => var await = 'test';", 7838 "var asyncFn = async () => var await = 'test';",
7843 "var asyncFn = async await => await + 'test';", 7839 "var asyncFn = async await => await + 'test';",
7844 "var asyncFn = async function(await) {};", 7840 "var asyncFn = async function(await) {};",
7845 "var asyncFn = async function() { return async (await) => {}; }",
7846 "var asyncFn = async (await) => 'test';", 7841 "var asyncFn = async (await) => 'test';",
7847 "var asyncFn = async x => { var await = 1; }",
7848 "var asyncFn = async x => { var { await } = 1; }",
7849 "var asyncFn = async x => { var [ await ] = 1; }",
7850 "async function f(await) {}", 7842 "async function f(await) {}",
7851 "async function f() { var await = 1; }",
7852 "async function f() { var { await } = 1; }",
7853 "async function f() { var [ await ] = 1; }",
7854 7843
7855 "var O = { async method(a, a) {} }", 7844 "var O = { async method(a, a) {} }",
7856 "var O = { async ['meth' + 'od'](a, a) {} }", 7845 "var O = { async ['meth' + 'od'](a, a) {} }",
7857 "var O = { async 'method'(a, a) {} }", 7846 "var O = { async 'method'(a, a) {} }",
7858 "var O = { async 0(a, a) {} }", 7847 "var O = { async 0(a, a) {} }",
7859 7848
7860 "async function f() { var O = { async [await](a, a) {} } }",
7861
7862 "var asyncFn = async function() { await; }",
7863 "async function f() { await; }",
7864 "var O = { async method() { await; } };",
7865 "var f = async() => await;", 7849 "var f = async() => await;",
7866 "var f = async() => { await; };",
7867
7868 "async function f() { return {await} }",
7869 7850
7870 "var asyncFn = async function*() {}", 7851 "var asyncFn = async function*() {}",
7871 "async function* f() {}", 7852 "async function* f() {}",
7872 "var O = { *async method() {} };", 7853 "var O = { *async method() {} };",
7873 "var O = { async *method() {} };", 7854 "var O = { async *method() {} };",
7874 "var O = { async method*() {} };", 7855 "var O = { async method*() {} };",
7875 7856
7876 "var asyncFn = async function(x = await 1) { return x; }", 7857 "var asyncFn = async function(x = await 1) { return x; }",
7877 "async function f(x = await 1) { return x; }", 7858 "async function f(x = await 1) { return x; }",
7878 "var f = async(x = await 1) => x;", 7859 "var f = async(x = await 1) => x;",
7879 "var O = { async method(x = await 1) { return x; } };", 7860 "var O = { async method(x = await 1) { return x; } };",
7880 7861
7881 "var f = async(x = await) => 1;", 7862 "var f = async(x = await) => 1;",
7882 7863
7883 "class C { async constructor() {} }", 7864 "class C { async constructor() {} }",
7884 "class C {}; class C2 extends C { async constructor() {} }", 7865 "class C {}; class C2 extends C { async constructor() {} }",
7885 "class C { static async prototype() {} }", 7866 "class C { static async prototype() {} }",
7886 "class C {}; class C2 extends C { static async prototype() {} }", 7867 "class C {}; class C2 extends C { static async prototype() {} }",
7887 7868
7888 "var f = async() => ((async(x = await 1) => x)();", 7869 "var f = async() => ((async(x = await 1) => x)();",
7889 7870
7890 "var asyncFn = async function() { function await() {} }",
7891 "var asyncFn = async() => { function await() {} }",
7892 "var O = { async method() { function await() {} } }",
7893 "async function foo() { function await() {} }",
7894
7895 // Henrique Ferreiro's bug (tm) 7871 // Henrique Ferreiro's bug (tm)
7896 "(async function foo1() { } foo2 => 1)", 7872 "(async function foo1() { } foo2 => 1)",
7897 "(async function foo3() { } () => 1)", 7873 "(async function foo3() { } () => 1)",
7898 "(async function foo4() { } => 1)", 7874 "(async function foo4() { } => 1)",
7899 "(async function() { } foo5 => 1)", 7875 "(async function() { } foo5 => 1)",
7900 "(async function() { } () => 1)", 7876 "(async function() { } () => 1)",
7901 "(async function() { } => 1)", 7877 "(async function() { } => 1)",
7902 "(async.foo6 => 1)", 7878 "(async.foo6 => 1)",
7903 "(async.foo7 foo8 => 1)", 7879 "(async.foo7 foo8 => 1)",
7904 "(async.foo9 () => 1)", 7880 "(async.foo9 () => 1)",
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
7969 // clang-format on 7945 // clang-format on
7970 7946
7971 static const ParserFlag always_flags[] = {kAllowHarmonyAsyncAwait}; 7947 static const ParserFlag always_flags[] = {kAllowHarmonyAsyncAwait};
7972 RunParserSyncTest(context_data, error_data, kError, NULL, 0, always_flags, 7948 RunParserSyncTest(context_data, error_data, kError, NULL, 0, always_flags,
7973 arraysize(always_flags)); 7949 arraysize(always_flags));
7974 RunParserSyncTest(strict_context_data, strict_error_data, kError, NULL, 0, 7950 RunParserSyncTest(strict_context_data, strict_error_data, kError, NULL, 0,
7975 always_flags, arraysize(always_flags)); 7951 always_flags, arraysize(always_flags));
7976 7952
7977 RunParserSyncTest(context_data, formal_parameters_data, kError, NULL, 0, 7953 RunParserSyncTest(context_data, formal_parameters_data, kError, NULL, 0,
7978 always_flags, arraysize(always_flags)); 7954 always_flags, arraysize(always_flags));
7955
7956 // clang-format off
7957 const char* async_body_context_data[][2] = {
7958 { "async function f() {", "}" },
7959 { "var f = async function() {", "}" },
7960 { "var f = async() => {", "}" },
7961 { "var O = { async method() {", "} }" },
7962 { "'use strict'; async function f() {", "}" },
7963 { "'use strict'; var f = async function() {", "}" },
7964 { "'use strict'; var f = async() => {", "}" },
7965 { "'use strict'; var O = { async method() {", "} }" },
7966 { NULL, NULL }
7967 };
7968
7969 const char* async_body_error_data[] = {
7970 "var await = 1;",
7971 "var { await } = 1;",
7972 "var [ await ] = 1;",
7973 "return async (await) => {};",
7974 "var O = { async [await](a, a) {} }",
7975 "await;",
7976
7977 "function await() {}",
7978
7979 "var f = await => 42;",
7980 "var f = (await) => 42;",
7981 "var f = (await, a) => 42;",
7982 "var f = (...await) => 42;",
7983
7984 "var e = (await);",
7985 "var e = (await, f);",
7986 "var e = (await = 42)",
7987
7988 "var e = [await];",
7989 "var e = {await};",
7990
7991 NULL
7992 };
7993 // clang-format on
7994
7995 RunParserSyncTest(async_body_context_data, async_body_error_data, kError,
7996 NULL, 0, always_flags, arraysize(always_flags));
7979 } 7997 }
7980 7998
7981 TEST(AsyncAwaitModule) { 7999 TEST(AsyncAwaitModule) {
7982 // clang-format off 8000 // clang-format off
7983 const char* context_data[][2] = { 8001 const char* context_data[][2] = {
7984 { "", "" }, 8002 { "", "" },
7985 { NULL, NULL } 8003 { NULL, NULL }
7986 }; 8004 };
7987 8005
7988 const char* data[] = { 8006 const char* data[] = {
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
8194 "(a,);", 8212 "(a,);",
8195 "(a,b,c,);", 8213 "(a,b,c,);",
8196 NULL 8214 NULL
8197 }; 8215 };
8198 // clang-format on 8216 // clang-format on
8199 8217
8200 static const ParserFlag always_flags[] = {kAllowHarmonyTrailingCommas}; 8218 static const ParserFlag always_flags[] = {kAllowHarmonyTrailingCommas};
8201 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, 8219 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags,
8202 arraysize(always_flags)); 8220 arraysize(always_flags));
8203 } 8221 }
OLDNEW
« no previous file with comments | « src/parsing/parser-base.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698