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

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

Issue 1656993002: [parser] report invalid rest parameter errors in Arrow functions (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: group tests/remove unneeded stuff Created 4 years, 10 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') | test/message/arrow-invalid-rest.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 3694 matching lines...) Expand 10 before | Expand all | Expand 10 after
3705 nullptr 3705 nullptr
3706 }; 3706 };
3707 3707
3708 RunParserSyncTest(context_data, assignment_expression_suffix_data, kError); 3708 RunParserSyncTest(context_data, assignment_expression_suffix_data, kError);
3709 } 3709 }
3710 3710
3711 3711
3712 TEST(ErrorsArrowFunctions) { 3712 TEST(ErrorsArrowFunctions) {
3713 // Tests that parser and preparser generate the same kind of errors 3713 // Tests that parser and preparser generate the same kind of errors
3714 // on invalid arrow function syntax. 3714 // on invalid arrow function syntax.
3715
3716 // clang-format off
3715 const char* context_data[][2] = { 3717 const char* context_data[][2] = {
3716 {"", ";"}, 3718 {"", ";"},
3717 {"v = ", ";"}, 3719 {"v = ", ";"},
3718 {"bar ? (", ") : baz;"}, 3720 {"bar ? (", ") : baz;"},
3719 {"bar ? baz : (", ");"}, 3721 {"bar ? baz : (", ");"},
3720 {"bar[", "];"}, 3722 {"bar[", "];"},
3721 {"bar, ", ";"}, 3723 {"bar, ", ";"},
3722 {"", ", bar;"}, 3724 {"", ", bar;"},
3723 {NULL, NULL} 3725 {NULL, NULL}
3724 }; 3726 };
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
3805 "(a = b) => {}", 3807 "(a = b) => {}",
3806 "(a = b, c) => {}", 3808 "(a = b, c) => {}",
3807 "(a, b = c) => {}", 3809 "(a, b = c) => {}",
3808 "(foo ? bar : baz) => {}", 3810 "(foo ? bar : baz) => {}",
3809 "(a, foo ? bar : baz) => {}", 3811 "(a, foo ? bar : baz) => {}",
3810 "(foo ? bar : baz, a) => {}", 3812 "(foo ? bar : baz, a) => {}",
3811 "(a.b, c) => {}", 3813 "(a.b, c) => {}",
3812 "(c, a.b) => {}", 3814 "(c, a.b) => {}",
3813 "(a['b'], c) => {}", 3815 "(a['b'], c) => {}",
3814 "(c, a['b']) => {}", 3816 "(c, a['b']) => {}",
3817
3818 // crbug.com/582626
3819 "(...rest - a) => b",
3820 "(a, ...b - 10) => b",
3821
3815 NULL 3822 NULL
3816 }; 3823 };
3824 // clang-format on
3817 3825
3818 // The test is quite slow, so run it with a reduced set of flags. 3826 // The test is quite slow, so run it with a reduced set of flags.
3819 static const ParserFlag flags[] = {kAllowLazy}; 3827 static const ParserFlag flags[] = {kAllowLazy};
3820 RunParserSyncTest(context_data, statement_data, kError, flags, 3828 RunParserSyncTest(context_data, statement_data, kError, flags,
3821 arraysize(flags)); 3829 arraysize(flags));
3822 3830
3823 // In a context where a concise arrow body is parsed with [~In] variant, 3831 // In a context where a concise arrow body is parsed with [~In] variant,
3824 // ensure that an error is reported in both full parser and preparser. 3832 // ensure that an error is reported in both full parser and preparser.
3825 const char* loop_context_data[][2] = {{"for (", "; 0;);"}, 3833 const char* loop_context_data[][2] = {{"for (", "; 0;);"},
3826 {nullptr, nullptr}}; 3834 {nullptr, nullptr}};
(...skipping 4142 matching lines...) Expand 10 before | Expand all | Expand 10 after
7969 RunParserSyncTest(sloppy_context_data, valid_data, kSuccess, NULL, 0, 7977 RunParserSyncTest(sloppy_context_data, valid_data, kSuccess, NULL, 0,
7970 always_flags, arraysize(always_flags)); 7978 always_flags, arraysize(always_flags));
7971 RunParserSyncTest(strict_context_data, valid_data, kError, NULL, 0, 7979 RunParserSyncTest(strict_context_data, valid_data, kError, NULL, 0,
7972 always_flags, arraysize(always_flags)); 7980 always_flags, arraysize(always_flags));
7973 RunModuleParserSyncTest(strict_context_data, valid_data, kError, NULL, 0, 7981 RunModuleParserSyncTest(strict_context_data, valid_data, kError, NULL, 0,
7974 always_flags, arraysize(always_flags)); 7982 always_flags, arraysize(always_flags));
7975 } 7983 }
7976 7984
7977 7985
7978 TEST(MiscSyntaxErrors) { 7986 TEST(MiscSyntaxErrors) {
7987 // clang-format off
7979 const char* context_data[][2] = { 7988 const char* context_data[][2] = {
7980 {"'use strict'", ""}, {"", ""}, {NULL, NULL}}; 7989 { "'use strict'", "" },
7981 const char* error_data[] = {"for (();;) {}", NULL}; 7990 { "", "" },
7991 { NULL, NULL }
7992 };
7993 const char* error_data[] = {
7994 "for (();;) {}",
7995
7996 // crbug.com/582626
7997 "{ NaN ,chA((evarA=new t ( l = !.0[((... co -a0([1]))=> greturnkf",
7998 NULL
7999 };
8000 // clang-format on
7982 8001
7983 RunParserSyncTest(context_data, error_data, kError, NULL, 0, NULL, 0); 8002 RunParserSyncTest(context_data, error_data, kError, NULL, 0, NULL, 0);
7984 } 8003 }
OLDNEW
« no previous file with comments | « src/parsing/parser-base.h ('k') | test/message/arrow-invalid-rest.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698