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

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

Issue 1309523005: In generators, "yield" cannot be an arrow formal parameter name (Closed) Base URL: https://chromium.googlesource.com/v8/v8@master
Patch Set: Created 5 years, 3 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/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
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 3804 matching lines...) Expand 10 before | Expand all | Expand 10 after
3815 kAllowStrongMode}; 3815 kAllowStrongMode};
3816 RunParserSyncTest(strong_context_data, statement_data, kError, NULL, 0, 3816 RunParserSyncTest(strong_context_data, statement_data, kError, NULL, 0,
3817 always_flags, arraysize(always_flags)); 3817 always_flags, arraysize(always_flags));
3818 RunParserSyncTest(strict_context_data, statement_data, kError, NULL, 0, 3818 RunParserSyncTest(strict_context_data, statement_data, kError, NULL, 0,
3819 always_flags, arraysize(always_flags)); 3819 always_flags, arraysize(always_flags));
3820 RunParserSyncTest(sloppy_context_data, statement_data, kSuccess, NULL, 0, 3820 RunParserSyncTest(sloppy_context_data, statement_data, kSuccess, NULL, 0,
3821 always_flags, arraysize(always_flags)); 3821 always_flags, arraysize(always_flags));
3822 } 3822 }
3823 3823
3824 3824
3825 TEST(ArrowFunctionsYieldParameterNameInGenerator) {
3826 const char* sloppy_function_context_data[][2] = {
3827 {"(function f() { (", "); });"},
3828 {NULL, NULL}
3829 };
3830
3831 const char* strict_function_context_data[][2] = {
3832 {"(function f() {'use strong'; (", "); });"},
3833 {"(function f() {'use strict'; (", "); });"},
3834 {NULL, NULL}
3835 };
3836
3837 const char* generator_context_data[][2] = {
3838 {"(function *g() {'use strong'; (", "); });"},
3839 {"(function *g() {'use strict'; (", "); });"},
3840 {"(function *g() { (", "); });"},
3841 {NULL, NULL}
3842 };
3843
3844 const char* arrow_data[] = {
3845 "yield => {}",
3846 "(yield) => {}",
3847 "(a, yield) => {}",
3848 "(yield, a) => {}",
3849 "(yield, ...a) => {}",
3850 "(a, ...yield) => {}",
3851 "({yield}) => {}",
3852 "([yield]) => {}",
3853 NULL
3854 };
3855
3856 static const ParserFlag always_flags[] = { kAllowHarmonyDestructuring,
3857 kAllowHarmonyRestParameters,
3858 kAllowHarmonyArrowFunctions,
3859 kAllowStrongMode};
3860 RunParserSyncTest(sloppy_function_context_data, arrow_data, kSuccess, NULL, 0,
3861 always_flags, arraysize(always_flags));
3862 RunParserSyncTest(strict_function_context_data, arrow_data, kError, NULL, 0,
3863 always_flags, arraysize(always_flags));
3864 RunParserSyncTest(generator_context_data, arrow_data, kError, NULL, 0,
3865 always_flags, arraysize(always_flags));
3866 }
3867
3868
3825 TEST(SuperNoErrors) { 3869 TEST(SuperNoErrors) {
3826 // Tests that parser and preparser accept 'super' keyword in right places. 3870 // Tests that parser and preparser accept 'super' keyword in right places.
3827 const char* context_data[][2] = { 3871 const char* context_data[][2] = {
3828 {"class C { m() { ", "; } }"}, 3872 {"class C { m() { ", "; } }"},
3829 {"class C { m() { k = ", "; } }"}, 3873 {"class C { m() { k = ", "; } }"},
3830 {"class C { m() { foo(", "); } }"}, 3874 {"class C { m() { foo(", "); } }"},
3831 {"class C { m() { () => ", "; } }"}, 3875 {"class C { m() { () => ", "; } }"},
3832 {NULL, NULL} 3876 {NULL, NULL}
3833 }; 3877 };
3834 3878
(...skipping 3060 matching lines...) Expand 10 before | Expand all | Expand 10 after
6895 "for (let x of []) {}", 6939 "for (let x of []) {}",
6896 NULL 6940 NULL
6897 }; 6941 };
6898 // clang-format on 6942 // clang-format on
6899 6943
6900 static const ParserFlag always_flags[] = {kAllowHarmonySloppy, 6944 static const ParserFlag always_flags[] = {kAllowHarmonySloppy,
6901 kAllowHarmonySloppyLet}; 6945 kAllowHarmonySloppyLet};
6902 RunParserSyncTest(context_data, data, kSuccess, NULL, 0, always_flags, 6946 RunParserSyncTest(context_data, data, kSuccess, NULL, 0, always_flags,
6903 arraysize(always_flags)); 6947 arraysize(always_flags));
6904 } 6948 }
OLDNEW
« no previous file with comments | « src/preparser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698