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

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

Issue 1416753009: [parser] early error when declaration Pattern missing Initializer (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: comments addressed Created 5 years, 1 month 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.cc ('k') | test/message/const-decl-no-init.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 6684 matching lines...) Expand 10 before | Expand all | Expand 10 after
6695 // clang-format off 6695 // clang-format off
6696 const char* data[] = { 6696 const char* data[] = {
6697 "yield", 6697 "yield",
6698 "[yield]", 6698 "[yield]",
6699 "{ x : yield }", 6699 "{ x : yield }",
6700 NULL}; 6700 NULL};
6701 // clang-format on 6701 // clang-format on
6702 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, 6702 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags,
6703 arraysize(always_flags)); 6703 arraysize(always_flags));
6704 } 6704 }
6705
6706 { // Declaration-specific errors
6707 const char* context_data[][2] = {{"'use strict'; var ", ""},
6708 {"'use strict'; let ", ""},
6709 {"'use strict'; const ", ""},
6710 {"'use strict'; for (var ", ";;) {}"},
6711 {"'use strict'; for (let ", ";;) {}"},
6712 {"'use strict'; for (const ", ";;) {}"},
6713 {"var ", ""},
6714 {"let ", ""},
6715 {"const ", ""},
6716 {"for (var ", ";;) {}"},
6717 {"for (let ", ";;) {}"},
6718 {"for (const ", ";;) {}"},
6719 {NULL, NULL}};
6720
6721 // clang-format off
6722 const char* data[] = {
6723 "{ a }",
6724 "[ a ]",
6725 NULL};
6726 // clang-format on
6727 static const ParserFlag always_flags[] = {kAllowHarmonyDestructuring,
6728 kAllowHarmonySloppyLet};
6729 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags,
6730 arraysize(always_flags));
6731 }
6705 } 6732 }
6706 6733
6707 6734
6708 TEST(DestructuringDisallowPatternsInForVarIn) { 6735 TEST(DestructuringDisallowPatternsInForVarIn) {
6709 i::FLAG_harmony_destructuring = true; 6736 i::FLAG_harmony_destructuring = true;
6710 static const ParserFlag always_flags[] = {kAllowHarmonyDestructuring}; 6737 static const ParserFlag always_flags[] = {kAllowHarmonyDestructuring};
6711 const char* context_data[][2] = { 6738 const char* context_data[][2] = {
6712 {"", ""}, {"function f() {", "}"}, {NULL, NULL}}; 6739 {"", ""}, {"function f() {", "}"}, {NULL, NULL}};
6713 // clang-format off 6740 // clang-format off
6714 const char* error_data[] = { 6741 const char* error_data[] = {
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
7181 const char* data[] = { 7208 const char* data[] = {
7182 "let", 7209 "let",
7183 "let = 1", 7210 "let = 1",
7184 "for (let = 1; let < 1; let++) {}", 7211 "for (let = 1; let < 1; let++) {}",
7185 "for (let in {}) {}", 7212 "for (let in {}) {}",
7186 "for (var let = 1; let < 1; let++) {}", 7213 "for (var let = 1; let < 1; let++) {}",
7187 "for (var let in {}) {}", 7214 "for (var let in {}) {}",
7188 "for (var [let] = 1; let < 1; let++) {}", 7215 "for (var [let] = 1; let < 1; let++) {}",
7189 "for (var [let] in {}) {}", 7216 "for (var [let] in {}) {}",
7190 "var let", 7217 "var let",
7191 "var [let]", 7218 "var [let] = []",
7192 "for (const let = 1; let < 1; let++) {}", 7219 "for (const let = 1; let < 1; let++) {}",
7193 "for (const let in {}) {}", 7220 "for (const let in {}) {}",
7194 "for (const [let] = 1; let < 1; let++) {}", 7221 "for (const [let] = 1; let < 1; let++) {}",
7195 "for (const [let] in {}) {}", 7222 "for (const [let] in {}) {}",
7196 "const let", 7223 "const let",
7197 "const [let]", 7224 "const [let] = []",
7198 NULL 7225 NULL
7199 }; 7226 };
7200 // clang-format on 7227 // clang-format on
7201 7228
7202 static const ParserFlag always_flags[] = { 7229 static const ParserFlag always_flags[] = {
7203 kAllowHarmonySloppy, kAllowHarmonySloppyLet, kAllowHarmonyDestructuring}; 7230 kAllowHarmonySloppy, kAllowHarmonySloppyLet, kAllowHarmonyDestructuring};
7204 RunParserSyncTest(context_data, data, kSuccess, NULL, 0, always_flags, 7231 RunParserSyncTest(context_data, data, kSuccess, NULL, 0, always_flags,
7205 arraysize(always_flags)); 7232 arraysize(always_flags));
7206 7233
7207 // Some things should be rejected even in sloppy mode 7234 // Some things should be rejected even in sloppy mode
(...skipping 20 matching lines...) Expand all
7228 NULL 7255 NULL
7229 }; 7256 };
7230 // clang-format on 7257 // clang-format on
7231 7258
7232 static const ParserFlag fail_flags[] = { 7259 static const ParserFlag fail_flags[] = {
7233 kAllowHarmonySloppy, kAllowHarmonySloppyLet, kNoLegacyConst, 7260 kAllowHarmonySloppy, kAllowHarmonySloppyLet, kNoLegacyConst,
7234 kAllowHarmonyDestructuring}; 7261 kAllowHarmonyDestructuring};
7235 RunParserSyncTest(context_data, fail_data, kError, NULL, 0, fail_flags, 7262 RunParserSyncTest(context_data, fail_data, kError, NULL, 0, fail_flags,
7236 arraysize(fail_flags)); 7263 arraysize(fail_flags));
7237 } 7264 }
OLDNEW
« no previous file with comments | « src/preparser.cc ('k') | test/message/const-decl-no-init.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698