| OLD | NEW |
| 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 1418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1429 kAllowHarmonyModules, | 1429 kAllowHarmonyModules, |
| 1430 kAllowHarmonyArrowFunctions, | 1430 kAllowHarmonyArrowFunctions, |
| 1431 kAllowHarmonyRestParameters, | 1431 kAllowHarmonyRestParameters, |
| 1432 kAllowHarmonySloppy, | 1432 kAllowHarmonySloppy, |
| 1433 kAllowHarmonyUnicode, | 1433 kAllowHarmonyUnicode, |
| 1434 kAllowHarmonyComputedPropertyNames, | 1434 kAllowHarmonyComputedPropertyNames, |
| 1435 kAllowHarmonySpreadCalls, | 1435 kAllowHarmonySpreadCalls, |
| 1436 kAllowHarmonyDestructuring, | 1436 kAllowHarmonyDestructuring, |
| 1437 kAllowHarmonySpreadArrays, | 1437 kAllowHarmonySpreadArrays, |
| 1438 kAllowHarmonyNewTarget, | 1438 kAllowHarmonyNewTarget, |
| 1439 kAllowStrongMode | 1439 kAllowStrongMode, |
| 1440 kNoLegacyConst |
| 1440 }; | 1441 }; |
| 1441 | 1442 |
| 1442 | 1443 |
| 1443 enum ParserSyncTestResult { | 1444 enum ParserSyncTestResult { |
| 1444 kSuccessOrError, | 1445 kSuccessOrError, |
| 1445 kSuccess, | 1446 kSuccess, |
| 1446 kError | 1447 kError |
| 1447 }; | 1448 }; |
| 1448 | 1449 |
| 1449 template <typename Traits> | 1450 template <typename Traits> |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1461 parser->set_allow_harmony_sloppy(flags.Contains(kAllowHarmonySloppy)); | 1462 parser->set_allow_harmony_sloppy(flags.Contains(kAllowHarmonySloppy)); |
| 1462 parser->set_allow_harmony_unicode(flags.Contains(kAllowHarmonyUnicode)); | 1463 parser->set_allow_harmony_unicode(flags.Contains(kAllowHarmonyUnicode)); |
| 1463 parser->set_allow_harmony_computed_property_names( | 1464 parser->set_allow_harmony_computed_property_names( |
| 1464 flags.Contains(kAllowHarmonyComputedPropertyNames)); | 1465 flags.Contains(kAllowHarmonyComputedPropertyNames)); |
| 1465 parser->set_allow_harmony_destructuring( | 1466 parser->set_allow_harmony_destructuring( |
| 1466 flags.Contains(kAllowHarmonyDestructuring)); | 1467 flags.Contains(kAllowHarmonyDestructuring)); |
| 1467 parser->set_allow_harmony_spread_arrays( | 1468 parser->set_allow_harmony_spread_arrays( |
| 1468 flags.Contains(kAllowHarmonySpreadArrays)); | 1469 flags.Contains(kAllowHarmonySpreadArrays)); |
| 1469 parser->set_allow_harmony_new_target(flags.Contains(kAllowHarmonyNewTarget)); | 1470 parser->set_allow_harmony_new_target(flags.Contains(kAllowHarmonyNewTarget)); |
| 1470 parser->set_allow_strong_mode(flags.Contains(kAllowStrongMode)); | 1471 parser->set_allow_strong_mode(flags.Contains(kAllowStrongMode)); |
| 1472 parser->set_allow_legacy_const(!flags.Contains(kNoLegacyConst)); |
| 1471 } | 1473 } |
| 1472 | 1474 |
| 1473 | 1475 |
| 1474 void TestParserSyncWithFlags(i::Handle<i::String> source, | 1476 void TestParserSyncWithFlags(i::Handle<i::String> source, |
| 1475 i::EnumSet<ParserFlag> flags, | 1477 i::EnumSet<ParserFlag> flags, |
| 1476 ParserSyncTestResult result) { | 1478 ParserSyncTestResult result) { |
| 1477 i::Isolate* isolate = CcTest::i_isolate(); | 1479 i::Isolate* isolate = CcTest::i_isolate(); |
| 1478 i::Factory* factory = isolate->factory(); | 1480 i::Factory* factory = isolate->factory(); |
| 1479 | 1481 |
| 1480 uintptr_t stack_limit = isolate->stack_guard()->real_climit(); | 1482 uintptr_t stack_limit = isolate->stack_guard()->real_climit(); |
| (...skipping 5274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6755 kAllowHarmonyNewTarget, | 6757 kAllowHarmonyNewTarget, |
| 6756 kAllowHarmonySloppy, | 6758 kAllowHarmonySloppy, |
| 6757 }; | 6759 }; |
| 6758 // clang-format on | 6760 // clang-format on |
| 6759 | 6761 |
| 6760 RunParserSyncTest(good_context_data, data, kSuccess, NULL, 0, always_flags, | 6762 RunParserSyncTest(good_context_data, data, kSuccess, NULL, 0, always_flags, |
| 6761 arraysize(always_flags)); | 6763 arraysize(always_flags)); |
| 6762 RunParserSyncTest(bad_context_data, data, kError, NULL, 0, always_flags, | 6764 RunParserSyncTest(bad_context_data, data, kError, NULL, 0, always_flags, |
| 6763 arraysize(always_flags)); | 6765 arraysize(always_flags)); |
| 6764 } | 6766 } |
| 6767 |
| 6768 |
| 6769 TEST(LegacyConst) { |
| 6770 // clang-format off |
| 6771 const char* context_data[][2] = { |
| 6772 {"", ""}, |
| 6773 {"{", "}"}, |
| 6774 {NULL, NULL} |
| 6775 }; |
| 6776 |
| 6777 const char* data[] = { |
| 6778 "const x", |
| 6779 "const x = 1", |
| 6780 "for (const x = 1; x < 1; x++) {}", |
| 6781 "for (const x in {}) {}", |
| 6782 "for (const x of []) {}", |
| 6783 NULL |
| 6784 }; |
| 6785 // clang-format on |
| 6786 |
| 6787 static const ParserFlag always_flags[] = {kNoLegacyConst}; |
| 6788 |
| 6789 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, |
| 6790 arraysize(always_flags)); |
| 6791 RunParserSyncTest(context_data, data, kSuccess); |
| 6792 } |
| OLD | NEW |