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

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

Issue 1170263002: Revert of [es6] Parsing of new.target (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 6 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.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 1368 matching lines...) Expand 10 before | Expand all | Expand 10 after
1379 kAllowHarmonyArrowFunctions, 1379 kAllowHarmonyArrowFunctions,
1380 kAllowHarmonyClasses, 1380 kAllowHarmonyClasses,
1381 kAllowHarmonyObjectLiterals, 1381 kAllowHarmonyObjectLiterals,
1382 kAllowHarmonyRestParameters, 1382 kAllowHarmonyRestParameters,
1383 kAllowHarmonySloppy, 1383 kAllowHarmonySloppy,
1384 kAllowHarmonyUnicode, 1384 kAllowHarmonyUnicode,
1385 kAllowHarmonyComputedPropertyNames, 1385 kAllowHarmonyComputedPropertyNames,
1386 kAllowHarmonySpreadCalls, 1386 kAllowHarmonySpreadCalls,
1387 kAllowHarmonyDestructuring, 1387 kAllowHarmonyDestructuring,
1388 kAllowHarmonySpreadArrays, 1388 kAllowHarmonySpreadArrays,
1389 kAllowHarmonyNewTarget,
1390 kAllowStrongMode 1389 kAllowStrongMode
1391 }; 1390 };
1392 1391
1393 1392
1394 enum ParserSyncTestResult { 1393 enum ParserSyncTestResult {
1395 kSuccessOrError, 1394 kSuccessOrError,
1396 kSuccess, 1395 kSuccess,
1397 kError 1396 kError
1398 }; 1397 };
1399 1398
(...skipping 13 matching lines...) Expand all
1413 parser->set_allow_harmony_spreadcalls( 1412 parser->set_allow_harmony_spreadcalls(
1414 flags.Contains(kAllowHarmonySpreadCalls)); 1413 flags.Contains(kAllowHarmonySpreadCalls));
1415 parser->set_allow_harmony_sloppy(flags.Contains(kAllowHarmonySloppy)); 1414 parser->set_allow_harmony_sloppy(flags.Contains(kAllowHarmonySloppy));
1416 parser->set_allow_harmony_unicode(flags.Contains(kAllowHarmonyUnicode)); 1415 parser->set_allow_harmony_unicode(flags.Contains(kAllowHarmonyUnicode));
1417 parser->set_allow_harmony_computed_property_names( 1416 parser->set_allow_harmony_computed_property_names(
1418 flags.Contains(kAllowHarmonyComputedPropertyNames)); 1417 flags.Contains(kAllowHarmonyComputedPropertyNames));
1419 parser->set_allow_harmony_destructuring( 1418 parser->set_allow_harmony_destructuring(
1420 flags.Contains(kAllowHarmonyDestructuring)); 1419 flags.Contains(kAllowHarmonyDestructuring));
1421 parser->set_allow_harmony_spread_arrays( 1420 parser->set_allow_harmony_spread_arrays(
1422 flags.Contains(kAllowHarmonySpreadArrays)); 1421 flags.Contains(kAllowHarmonySpreadArrays));
1423 parser->set_allow_harmony_new_target(flags.Contains(kAllowHarmonyNewTarget));
1424 parser->set_allow_strong_mode(flags.Contains(kAllowStrongMode)); 1422 parser->set_allow_strong_mode(flags.Contains(kAllowStrongMode));
1425 } 1423 }
1426 1424
1427 1425
1428 void TestParserSyncWithFlags(i::Handle<i::String> source, 1426 void TestParserSyncWithFlags(i::Handle<i::String> source,
1429 i::EnumSet<ParserFlag> flags, 1427 i::EnumSet<ParserFlag> flags,
1430 ParserSyncTestResult result) { 1428 ParserSyncTestResult result) {
1431 i::Isolate* isolate = CcTest::i_isolate(); 1429 i::Isolate* isolate = CcTest::i_isolate();
1432 i::Factory* factory = isolate->factory(); 1430 i::Factory* factory = isolate->factory();
1433 1431
(...skipping 5176 matching lines...) Expand 10 before | Expand all | Expand 10 after
6610 "[a, ...]", 6608 "[a, ...]",
6611 "[..., ]", 6609 "[..., ]",
6612 "[..., ...]", 6610 "[..., ...]",
6613 "[ (...a)]", 6611 "[ (...a)]",
6614 NULL}; 6612 NULL};
6615 // clang-format on 6613 // clang-format on
6616 static const ParserFlag always_flags[] = {kAllowHarmonySpreadArrays}; 6614 static const ParserFlag always_flags[] = {kAllowHarmonySpreadArrays};
6617 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, 6615 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags,
6618 arraysize(always_flags)); 6616 arraysize(always_flags));
6619 } 6617 }
6620
6621
6622 TEST(NewTarget) {
6623 // clang-format off
6624 const char* good_context_data[][2] = {
6625 {"function f() {", "}"},
6626 {"'use strict'; function f() {", "}"},
6627 {"var f = function() {", "}"},
6628 {"'use strict'; var f = function() {", "}"},
6629 {"({m: function() {", "}})"},
6630 {"'use strict'; ({m: function() {", "}})"},
6631 {"({m() {", "}})"},
6632 {"'use strict'; ({m() {", "}})"},
6633 {"({get x() {", "}})"},
6634 {"'use strict'; ({get x() {", "}})"},
6635 {"({set x(_) {", "}})"},
6636 {"'use strict'; ({set x(_) {", "}})"},
6637 {"class C {m() {", "}}"},
6638 {"class C {get x() {", "}}"},
6639 {"class C {set x(_) {", "}}"},
6640 {NULL}
6641 };
6642
6643 const char* bad_context_data[][2] = {
6644 {"", ""},
6645 {"'use strict';", ""},
6646 {NULL}
6647 };
6648
6649 const char* data[] = {
6650 "new.target",
6651 "{ new.target }",
6652 "() => { new.target }",
6653 "() => new.target",
6654 "if (1) { new.target }",
6655 "if (1) {} else { new.target }",
6656 "while (0) { new.target }",
6657 "do { new.target } while (0)",
6658 NULL
6659 };
6660
6661 static const ParserFlag always_flags[] = {
6662 kAllowHarmonyArrowFunctions,
6663 kAllowHarmonyClasses,
6664 kAllowHarmonyNewTarget,
6665 kAllowHarmonyObjectLiterals,
6666 kAllowHarmonySloppy,
6667 };
6668 // clang-format on
6669
6670 RunParserSyncTest(good_context_data, data, kSuccess, NULL, 0, always_flags,
6671 arraysize(always_flags));
6672 RunParserSyncTest(bad_context_data, data, kError, NULL, 0, always_flags,
6673 arraysize(always_flags));
6674 }
OLDNEW
« no previous file with comments | « src/preparser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698