| OLD | NEW |
| 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 7486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7497 "var asyncFn = async function() { await 1; };", | 7497 "var asyncFn = async function() { await 1; };", |
| 7498 "var asyncFn = async function withName() { await 1; };", | 7498 "var asyncFn = async function withName() { await 1; };", |
| 7499 "var asyncFn = async () => await 'test';", | 7499 "var asyncFn = async () => await 'test';", |
| 7500 "var asyncFn = async x => await x + 'test';", | 7500 "var asyncFn = async x => await x + 'test';", |
| 7501 "async function asyncFn() { await 1; }", | 7501 "async function asyncFn() { await 1; }", |
| 7502 "var O = { async method() { await 1; } }", | 7502 "var O = { async method() { await 1; } }", |
| 7503 "var O = { async ['meth' + 'od']() { await 1; } }", | 7503 "var O = { async ['meth' + 'od']() { await 1; } }", |
| 7504 "var O = { async 'method'() { await 1; } }", | 7504 "var O = { async 'method'() { await 1; } }", |
| 7505 "var O = { async 0() { await 1; } }", | 7505 "var O = { async 0() { await 1; } }", |
| 7506 "async function await() {}", | 7506 "async function await() {}", |
| 7507 |
| 7508 "var asyncFn = async({ foo = 1 }) => foo;", |
| 7509 "var asyncFn = async({ foo = 1 } = {}) => foo;", |
| 7507 NULL | 7510 NULL |
| 7508 }; | 7511 }; |
| 7509 // clang-format on | 7512 // clang-format on |
| 7510 | 7513 |
| 7511 static const ParserFlag always_flags[] = {kAllowHarmonyAsyncAwait}; | 7514 static const ParserFlag always_flags[] = {kAllowHarmonyAsyncAwait}; |
| 7512 RunParserSyncTest(context_data, data, kSuccess, NULL, 0, always_flags, | 7515 RunParserSyncTest(context_data, data, kSuccess, NULL, 0, always_flags, |
| 7513 arraysize(always_flags)); | 7516 arraysize(always_flags)); |
| 7514 | 7517 |
| 7515 // clang-format off | 7518 // clang-format off |
| 7516 const char* async_body_context_data[][2] = { | 7519 const char* async_body_context_data[][2] = { |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7658 "(async['foo'] () => 1)", | 7661 "(async['foo'] () => 1)", |
| 7659 "(async()['foo'] => 1)", | 7662 "(async()['foo'] => 1)", |
| 7660 "(async()['foo'] foo => 1)", | 7663 "(async()['foo'] foo => 1)", |
| 7661 "(async()['foo'] () => 1)", | 7664 "(async()['foo'] () => 1)", |
| 7662 "(async`foo` => 1)", | 7665 "(async`foo` => 1)", |
| 7663 "(async`foo` foo => 1)", | 7666 "(async`foo` foo => 1)", |
| 7664 "(async`foo` () => 1)", | 7667 "(async`foo` () => 1)", |
| 7665 "(async`foo`.bar => 1)", | 7668 "(async`foo`.bar => 1)", |
| 7666 "(async`foo`.bar foo => 1)", | 7669 "(async`foo`.bar foo => 1)", |
| 7667 "(async`foo`.bar () => 1)", | 7670 "(async`foo`.bar () => 1)", |
| 7671 |
| 7672 // v8:5148 assert that errors are still thrown for calls that may have been |
| 7673 // async functions |
| 7674 "async({ foo = 1 })", |
| 7668 NULL | 7675 NULL |
| 7669 }; | 7676 }; |
| 7670 | 7677 |
| 7671 const char* strict_error_data[] = { | 7678 const char* strict_error_data[] = { |
| 7672 "var O = { async method(eval) {} }", | 7679 "var O = { async method(eval) {} }", |
| 7673 "var O = { async ['meth' + 'od'](eval) {} }", | 7680 "var O = { async ['meth' + 'od'](eval) {} }", |
| 7674 "var O = { async 'method'(eval) {} }", | 7681 "var O = { async 'method'(eval) {} }", |
| 7675 "var O = { async 0(eval) {} }", | 7682 "var O = { async 0(eval) {} }", |
| 7676 | 7683 |
| 7677 "var O = { async method(arguments) {} }", | 7684 "var O = { async method(arguments) {} }", |
| 7678 "var O = { async ['meth' + 'od'](arguments) {} }", | 7685 "var O = { async ['meth' + 'od'](arguments) {} }", |
| 7679 "var O = { async 'method'(arguments) {} }", | 7686 "var O = { async 'method'(arguments) {} }", |
| 7680 "var O = { async 0(arguments) {} }", | 7687 "var O = { async 0(arguments) {} }", |
| 7681 | 7688 |
| 7682 "var O = { async method(dupe, dupe) {} }", | 7689 "var O = { async method(dupe, dupe) {} }", |
| 7683 | 7690 |
| 7684 // TODO(caitp): preparser needs to report duplicate parameter errors, too. | 7691 // TODO(caitp): preparser needs to report duplicate parameter errors, too. |
| 7685 // "var f = async(dupe, dupe) => {}", | 7692 // "var f = async(dupe, dupe) => {}", |
| 7686 | 7693 |
| 7687 NULL | 7694 NULL |
| 7688 }; | 7695 }; |
| 7696 |
| 7697 const char* formal_parameters_data[] = { |
| 7698 "var f = async({ await }) => 1;", |
| 7699 "var f = async({ await = 1 }) => 1;", |
| 7700 "var f = async({ await } = {}) => 1;", |
| 7701 "var f = async({ await = 1 } = {}) => 1;", |
| 7702 "var f = async([await]) => 1;", |
| 7703 "var f = async([await] = []) => 1;", |
| 7704 "var f = async([await = 1]) => 1;", |
| 7705 "var f = async([await = 1] = []) => 1;", |
| 7706 "var f = async(...await) => 1;", |
| 7707 "var f = async(await) => 1;", |
| 7708 "var f = async(await = 1) => 1;", |
| 7709 "var f = async(...[await]) => 1;", |
| 7710 NULL |
| 7711 }; |
| 7689 // clang-format on | 7712 // clang-format on |
| 7690 | 7713 |
| 7691 static const ParserFlag always_flags[] = {kAllowHarmonyAsyncAwait}; | 7714 static const ParserFlag always_flags[] = {kAllowHarmonyAsyncAwait}; |
| 7692 RunParserSyncTest(context_data, error_data, kError, NULL, 0, always_flags, | 7715 RunParserSyncTest(context_data, error_data, kError, NULL, 0, always_flags, |
| 7693 arraysize(always_flags)); | 7716 arraysize(always_flags)); |
| 7694 RunParserSyncTest(strict_context_data, strict_error_data, kError, NULL, 0, | 7717 RunParserSyncTest(strict_context_data, strict_error_data, kError, NULL, 0, |
| 7695 always_flags, arraysize(always_flags)); | 7718 always_flags, arraysize(always_flags)); |
| 7719 { |
| 7720 // TODO(caitp): support these early errors in preparser |
| 7721 USE(formal_parameters_data); |
| 7722 // const bool kIsModule = false; |
| 7723 // const bool kTestPreparser = false; |
| 7724 // TODO(caitp): These tests seem to fail test-parsing.cc, even with |
| 7725 // test_preparser disabled. |
| 7726 // RunParserSyncTest(context_data, formal_parameters_data, kError, NULL, 0, |
| 7727 // always_flags, arraysize(always_flags), NULL, 0, |
| 7728 // kIsModule, kTestPreparser); |
| 7729 } |
| 7696 } | 7730 } |
| 7697 | 7731 |
| 7698 TEST(AsyncAwaitModule) { | 7732 TEST(AsyncAwaitModule) { |
| 7699 // clang-format off | 7733 // clang-format off |
| 7700 const char* context_data[][2] = { | 7734 const char* context_data[][2] = { |
| 7701 { "", "" }, | 7735 { "", "" }, |
| 7702 { NULL, NULL } | 7736 { NULL, NULL } |
| 7703 }; | 7737 }; |
| 7704 | 7738 |
| 7705 const char* data[] = { | 7739 const char* data[] = { |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7807 NULL}; | 7841 NULL}; |
| 7808 static const ParserFlag always_flags[] = {kAllowHarmonyAsyncAwait}; | 7842 static const ParserFlag always_flags[] = {kAllowHarmonyAsyncAwait}; |
| 7809 // The preparser doesn't enforce the restriction, so turn it off. | 7843 // The preparser doesn't enforce the restriction, so turn it off. |
| 7810 bool test_preparser = false; | 7844 bool test_preparser = false; |
| 7811 RunParserSyncTest(block_context_data, error_data, kError, NULL, 0, | 7845 RunParserSyncTest(block_context_data, error_data, kError, NULL, 0, |
| 7812 always_flags, arraysize(always_flags), NULL, 0, false, | 7846 always_flags, arraysize(always_flags), NULL, 0, false, |
| 7813 test_preparser); | 7847 test_preparser); |
| 7814 RunParserSyncTest(top_level_context_data, error_data, kSuccess, NULL, 0, | 7848 RunParserSyncTest(top_level_context_data, error_data, kSuccess, NULL, 0, |
| 7815 always_flags, arraysize(always_flags)); | 7849 always_flags, arraysize(always_flags)); |
| 7816 } | 7850 } |
| OLD | NEW |