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

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

Issue 1913203002: Widen --harmony-for-in flag to throw errors in PreParser (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 8 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/preparser.cc ('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 1490 matching lines...) Expand 10 before | Expand all | Expand 10 after
1501 data.Dispose(); 1501 data.Dispose();
1502 return i::MessageTemplate::FormatMessage(isolate, message, arg_object); 1502 return i::MessageTemplate::FormatMessage(isolate, message, arg_object);
1503 } 1503 }
1504 1504
1505 enum ParserFlag { 1505 enum ParserFlag {
1506 kAllowLazy, 1506 kAllowLazy,
1507 kAllowNatives, 1507 kAllowNatives,
1508 kAllowHarmonyNewTarget, 1508 kAllowHarmonyNewTarget,
1509 kAllowHarmonyFunctionSent, 1509 kAllowHarmonyFunctionSent,
1510 kAllowHarmonyRestrictiveDeclarations, 1510 kAllowHarmonyRestrictiveDeclarations,
1511 kAllowHarmonyExponentiationOperator 1511 kAllowHarmonyExponentiationOperator,
1512 kAllowHarmonyForIn
1512 }; 1513 };
1513 1514
1514 enum ParserSyncTestResult { 1515 enum ParserSyncTestResult {
1515 kSuccessOrError, 1516 kSuccessOrError,
1516 kSuccess, 1517 kSuccess,
1517 kError 1518 kError
1518 }; 1519 };
1519 1520
1520 template <typename Traits> 1521 template <typename Traits>
1521 void SetParserFlags(i::ParserBase<Traits>* parser, 1522 void SetParserFlags(i::ParserBase<Traits>* parser,
1522 i::EnumSet<ParserFlag> flags) { 1523 i::EnumSet<ParserFlag> flags) {
1523 parser->set_allow_lazy(flags.Contains(kAllowLazy)); 1524 parser->set_allow_lazy(flags.Contains(kAllowLazy));
1524 parser->set_allow_natives(flags.Contains(kAllowNatives)); 1525 parser->set_allow_natives(flags.Contains(kAllowNatives));
1525 parser->set_allow_harmony_function_sent( 1526 parser->set_allow_harmony_function_sent(
1526 flags.Contains(kAllowHarmonyFunctionSent)); 1527 flags.Contains(kAllowHarmonyFunctionSent));
1527 parser->set_allow_harmony_restrictive_declarations( 1528 parser->set_allow_harmony_restrictive_declarations(
1528 flags.Contains(kAllowHarmonyRestrictiveDeclarations)); 1529 flags.Contains(kAllowHarmonyRestrictiveDeclarations));
1529 parser->set_allow_harmony_exponentiation_operator( 1530 parser->set_allow_harmony_exponentiation_operator(
1530 flags.Contains(kAllowHarmonyExponentiationOperator)); 1531 flags.Contains(kAllowHarmonyExponentiationOperator));
1532 parser->set_allow_harmony_for_in(flags.Contains(kAllowHarmonyForIn));
1531 } 1533 }
1532 1534
1533 1535
1534 void TestParserSyncWithFlags(i::Handle<i::String> source, 1536 void TestParserSyncWithFlags(i::Handle<i::String> source,
1535 i::EnumSet<ParserFlag> flags, 1537 i::EnumSet<ParserFlag> flags,
1536 ParserSyncTestResult result, 1538 ParserSyncTestResult result,
1537 bool is_module = false) { 1539 bool is_module = false) {
1538 i::Isolate* isolate = CcTest::i_isolate(); 1540 i::Isolate* isolate = CcTest::i_isolate();
1539 i::Factory* factory = isolate->factory(); 1541 i::Factory* factory = isolate->factory();
1540 1542
(...skipping 5719 matching lines...) Expand 10 before | Expand all | Expand 10 after
7260 // "Array() **= 10", 7262 // "Array() **= 10",
7261 NULL 7263 NULL
7262 }; 7264 };
7263 // clang-format on 7265 // clang-format on
7264 7266
7265 static const ParserFlag always_flags[] = { 7267 static const ParserFlag always_flags[] = {
7266 kAllowHarmonyExponentiationOperator}; 7268 kAllowHarmonyExponentiationOperator};
7267 RunParserSyncTest(context_data, error_data, kError, NULL, 0, always_flags, 7269 RunParserSyncTest(context_data, error_data, kError, NULL, 0, always_flags,
7268 arraysize(always_flags)); 7270 arraysize(always_flags));
7269 } 7271 }
7272
7273 TEST(RestrictiveForInErrors) {
7274 // clang-format off
7275 const char* context_data[][2] = {
7276 { "'use strict'", "" },
7277 { "", "" },
7278 { NULL, NULL }
7279 };
7280 const char* error_data[] = {
7281 "for (var x = 0 in {});",
7282 "for (const x = 0 in {});",
7283 "for (let x = 0 in {});",
7284 NULL
7285 };
7286 // clang-format on
7287
7288 static const ParserFlag always_flags[] = {kAllowHarmonyForIn};
7289 RunParserSyncTest(context_data, error_data, kError, nullptr, 0, always_flags,
7290 arraysize(always_flags));
7291 }
OLDNEW
« no previous file with comments | « src/parsing/preparser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698