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

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

Issue 1027593005: [es6] remove --harmony-templates flag (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Remove extra references to harmony-templates stuff Created 5 years, 9 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/templates.js ('k') | test/js-perf-test/JSTests.json » ('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 1360 matching lines...) Expand 10 before | Expand all | Expand 10 after
1371 1371
1372 enum ParserFlag { 1372 enum ParserFlag {
1373 kAllowLazy, 1373 kAllowLazy,
1374 kAllowNatives, 1374 kAllowNatives,
1375 kAllowHarmonyModules, 1375 kAllowHarmonyModules,
1376 kAllowHarmonyNumericLiterals, 1376 kAllowHarmonyNumericLiterals,
1377 kAllowHarmonyArrowFunctions, 1377 kAllowHarmonyArrowFunctions,
1378 kAllowHarmonyClasses, 1378 kAllowHarmonyClasses,
1379 kAllowHarmonyObjectLiterals, 1379 kAllowHarmonyObjectLiterals,
1380 kAllowHarmonyRestParameters, 1380 kAllowHarmonyRestParameters,
1381 kAllowHarmonyTemplates,
1382 kAllowHarmonySloppy, 1381 kAllowHarmonySloppy,
1383 kAllowHarmonyUnicode, 1382 kAllowHarmonyUnicode,
1384 kAllowHarmonyComputedPropertyNames, 1383 kAllowHarmonyComputedPropertyNames,
1385 kAllowStrongMode 1384 kAllowStrongMode
1386 }; 1385 };
1387 1386
1388 1387
1389 enum ParserSyncTestResult { 1388 enum ParserSyncTestResult {
1390 kSuccessOrError, 1389 kSuccessOrError,
1391 kSuccess, 1390 kSuccess,
1392 kError 1391 kError
1393 }; 1392 };
1394 1393
1395 template <typename Traits> 1394 template <typename Traits>
1396 void SetParserFlags(i::ParserBase<Traits>* parser, 1395 void SetParserFlags(i::ParserBase<Traits>* parser,
1397 i::EnumSet<ParserFlag> flags) { 1396 i::EnumSet<ParserFlag> flags) {
1398 parser->set_allow_lazy(flags.Contains(kAllowLazy)); 1397 parser->set_allow_lazy(flags.Contains(kAllowLazy));
1399 parser->set_allow_natives(flags.Contains(kAllowNatives)); 1398 parser->set_allow_natives(flags.Contains(kAllowNatives));
1400 parser->set_allow_harmony_modules(flags.Contains(kAllowHarmonyModules)); 1399 parser->set_allow_harmony_modules(flags.Contains(kAllowHarmonyModules));
1401 parser->set_allow_harmony_numeric_literals( 1400 parser->set_allow_harmony_numeric_literals(
1402 flags.Contains(kAllowHarmonyNumericLiterals)); 1401 flags.Contains(kAllowHarmonyNumericLiterals));
1403 parser->set_allow_harmony_object_literals( 1402 parser->set_allow_harmony_object_literals(
1404 flags.Contains(kAllowHarmonyObjectLiterals)); 1403 flags.Contains(kAllowHarmonyObjectLiterals));
1405 parser->set_allow_harmony_arrow_functions( 1404 parser->set_allow_harmony_arrow_functions(
1406 flags.Contains(kAllowHarmonyArrowFunctions)); 1405 flags.Contains(kAllowHarmonyArrowFunctions));
1407 parser->set_allow_harmony_classes(flags.Contains(kAllowHarmonyClasses)); 1406 parser->set_allow_harmony_classes(flags.Contains(kAllowHarmonyClasses));
1408 parser->set_allow_harmony_templates(flags.Contains(kAllowHarmonyTemplates));
1409 parser->set_allow_harmony_rest_params( 1407 parser->set_allow_harmony_rest_params(
1410 flags.Contains(kAllowHarmonyRestParameters)); 1408 flags.Contains(kAllowHarmonyRestParameters));
1411 parser->set_allow_harmony_sloppy(flags.Contains(kAllowHarmonySloppy)); 1409 parser->set_allow_harmony_sloppy(flags.Contains(kAllowHarmonySloppy));
1412 parser->set_allow_harmony_unicode(flags.Contains(kAllowHarmonyUnicode)); 1410 parser->set_allow_harmony_unicode(flags.Contains(kAllowHarmonyUnicode));
1413 parser->set_allow_harmony_computed_property_names( 1411 parser->set_allow_harmony_computed_property_names(
1414 flags.Contains(kAllowHarmonyComputedPropertyNames)); 1412 flags.Contains(kAllowHarmonyComputedPropertyNames));
1415 parser->set_allow_strong_mode(flags.Contains(kAllowStrongMode)); 1413 parser->set_allow_strong_mode(flags.Contains(kAllowStrongMode));
1416 } 1414 }
1417 1415
1418 1416
(...skipping 3278 matching lines...) Expand 10 before | Expand all | Expand 10 after
4697 "`foo${a \n}`", 4695 "`foo${a \n}`",
4698 "`foo${a \r\n}`", 4696 "`foo${a \r\n}`",
4699 "`foo${a \r}`", 4697 "`foo${a \r}`",
4700 "`foo${/* comment */ a}`", 4698 "`foo${/* comment */ a}`",
4701 "`foo${// comment\na}`", 4699 "`foo${// comment\na}`",
4702 "`foo${\n a}`", 4700 "`foo${\n a}`",
4703 "`foo${\r\n a}`", 4701 "`foo${\r\n a}`",
4704 "`foo${\r a}`", 4702 "`foo${\r a}`",
4705 "`foo${'a' in a}`", 4703 "`foo${'a' in a}`",
4706 NULL}; 4704 NULL};
4707 static const ParserFlag always_flags[] = {kAllowHarmonyTemplates}; 4705 RunParserSyncTest(context_data, data, kSuccess, NULL, 0, NULL, 0);
4708 RunParserSyncTest(context_data, data, kSuccess, NULL, 0, always_flags,
4709 arraysize(always_flags));
4710 } 4706 }
4711 4707
4712 4708
4713 TEST(ScanTaggedTemplateLiterals) { 4709 TEST(ScanTaggedTemplateLiterals) {
4714 const char* context_data[][2] = {{"'use strict';", ""}, 4710 const char* context_data[][2] = {{"'use strict';", ""},
4715 {"function foo(){ 'use strict';" 4711 {"function foo(){ 'use strict';"
4716 " function tag() {}" 4712 " function tag() {}"
4717 " var a, b, c; return ", "}"}, 4713 " var a, b, c; return ", "}"},
4718 {NULL, NULL}}; 4714 {NULL, NULL}};
4719 4715
(...skipping 14 matching lines...) Expand all
4734 "tag`foo${a \n}`", 4730 "tag`foo${a \n}`",
4735 "tag`foo${a \r\n}`", 4731 "tag`foo${a \r\n}`",
4736 "tag`foo${a \r}`", 4732 "tag`foo${a \r}`",
4737 "tag`foo${/* comment */ a}`", 4733 "tag`foo${/* comment */ a}`",
4738 "tag`foo${// comment\na}`", 4734 "tag`foo${// comment\na}`",
4739 "tag`foo${\n a}`", 4735 "tag`foo${\n a}`",
4740 "tag`foo${\r\n a}`", 4736 "tag`foo${\r\n a}`",
4741 "tag`foo${\r a}`", 4737 "tag`foo${\r a}`",
4742 "tag`foo${'a' in a}`", 4738 "tag`foo${'a' in a}`",
4743 NULL}; 4739 NULL};
4744 static const ParserFlag always_flags[] = {kAllowHarmonyTemplates}; 4740 RunParserSyncTest(context_data, data, kSuccess, NULL, 0, NULL, 0);
4745 RunParserSyncTest(context_data, data, kSuccess, NULL, 0, always_flags,
4746 arraysize(always_flags));
4747 } 4741 }
4748 4742
4749 4743
4750 TEST(TemplateMaterializedLiterals) { 4744 TEST(TemplateMaterializedLiterals) {
4751 const char* context_data[][2] = { 4745 const char* context_data[][2] = {
4752 { 4746 {
4753 "'use strict';\n" 4747 "'use strict';\n"
4754 "function tag() {}\n" 4748 "function tag() {}\n"
4755 "var a, b, c;\n" 4749 "var a, b, c;\n"
4756 "(", ")" 4750 "(", ")"
4757 }, 4751 },
4758 {NULL, NULL} 4752 {NULL, NULL}
4759 }; 4753 };
4760 4754
4761 const char* data[] = { 4755 const char* data[] = {
4762 "tag``", 4756 "tag``",
4763 "tag`a`", 4757 "tag`a`",
4764 "tag`a${1}b`", 4758 "tag`a${1}b`",
4765 "tag`a${1}b${2}c`", 4759 "tag`a${1}b${2}c`",
4766 "``", 4760 "``",
4767 "`a`", 4761 "`a`",
4768 "`a${1}b`", 4762 "`a${1}b`",
4769 "`a${1}b${2}c`", 4763 "`a${1}b${2}c`",
4770 NULL 4764 NULL
4771 }; 4765 };
4772 4766
4773 static const ParserFlag always_flags[] = {kAllowHarmonyTemplates}; 4767 RunParserSyncTest(context_data, data, kSuccess, NULL, 0, NULL, 0);
4774 RunParserSyncTest(context_data, data, kSuccess, NULL, 0, always_flags,
4775 arraysize(always_flags));
4776 } 4768 }
4777 4769
4778 4770
4779 TEST(ScanUnterminatedTemplateLiterals) { 4771 TEST(ScanUnterminatedTemplateLiterals) {
4780 const char* context_data[][2] = {{"'use strict';", ""}, 4772 const char* context_data[][2] = {{"'use strict';", ""},
4781 {"function foo(){ 'use strict';" 4773 {"function foo(){ 'use strict';"
4782 " var a, b, c; return ", "}"}, 4774 " var a, b, c; return ", "}"},
4783 {NULL, NULL}}; 4775 {NULL, NULL}};
4784 4776
4785 const char* data[] = { 4777 const char* data[] = {
(...skipping 13 matching lines...) Expand all
4799 "`foo${a \r\n`", 4791 "`foo${a \r\n`",
4800 "`foo${a \r`", 4792 "`foo${a \r`",
4801 "`foo${/* comment */ a`", 4793 "`foo${/* comment */ a`",
4802 "`foo${// commenta}`", 4794 "`foo${// commenta}`",
4803 "`foo${\n a`", 4795 "`foo${\n a`",
4804 "`foo${\r\n a`", 4796 "`foo${\r\n a`",
4805 "`foo${\r a`", 4797 "`foo${\r a`",
4806 "`foo${fn(}`", 4798 "`foo${fn(}`",
4807 "`foo${1 if}`", 4799 "`foo${1 if}`",
4808 NULL}; 4800 NULL};
4809 static const ParserFlag always_flags[] = {kAllowHarmonyTemplates}; 4801 RunParserSyncTest(context_data, data, kError, NULL, 0, NULL, 0);
4810 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags,
4811 arraysize(always_flags));
4812 } 4802 }
4813 4803
4814 4804
4815 TEST(TemplateLiteralsIllegalTokens) { 4805 TEST(TemplateLiteralsIllegalTokens) {
4816 const char* context_data[][2] = {{"'use strict';", ""}, 4806 const char* context_data[][2] = {{"'use strict';", ""},
4817 {"function foo(){ 'use strict';" 4807 {"function foo(){ 'use strict';"
4818 " var a, b, c; return ", "}"}, 4808 " var a, b, c; return ", "}"},
4819 {NULL, NULL}}; 4809 {NULL, NULL}};
4820 const char* data[] = { 4810 const char* data[] = {
4821 "`hello\\x`", 4811 "`hello\\x`",
4822 "`hello\\x${1}`", 4812 "`hello\\x${1}`",
4823 "`hello${1}\\x`", 4813 "`hello${1}\\x`",
4824 "`hello${1}\\x${2}`", 4814 "`hello${1}\\x${2}`",
4825 "`hello\\x\n`", 4815 "`hello\\x\n`",
4826 "`hello\\x\n${1}`", 4816 "`hello\\x\n${1}`",
4827 "`hello${1}\\x\n`", 4817 "`hello${1}\\x\n`",
4828 "`hello${1}\\x\n${2}`", 4818 "`hello${1}\\x\n${2}`",
4829 NULL}; 4819 NULL};
4830 4820
4831 static const ParserFlag always_flags[] = {kAllowHarmonyTemplates}; 4821 RunParserSyncTest(context_data, data, kError, NULL, 0, NULL, 0);
4832 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags,
4833 arraysize(always_flags));
4834 } 4822 }
4835 4823
4836 4824
4837 TEST(ParseRestParameters) { 4825 TEST(ParseRestParameters) {
4838 const char* context_data[][2] = {{"'use strict';(function(", 4826 const char* context_data[][2] = {{"'use strict';(function(",
4839 "){ return args;})(1, [], /regexp/, 'str'," 4827 "){ return args;})(1, [], /regexp/, 'str',"
4840 "function(){});"}, 4828 "function(){});"},
4841 {"(function(", "){ return args;})(1, []," 4829 {"(function(", "){ return args;})(1, [],"
4842 "/regexp/, 'str', function(){});"}, 4830 "/regexp/, 'str', function(){});"},
4843 {NULL, NULL}}; 4831 {NULL, NULL}};
(...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after
5643 "(a/*\n*/=> a)(1)", 5631 "(a/*\n*/=> a)(1)",
5644 "((a)\n=> a)(1)", 5632 "((a)\n=> a)(1)",
5645 "((a)/*\n*/=> a)(1)", 5633 "((a)/*\n*/=> a)(1)",
5646 "((a, b)\n=> a + b)(1, 2)", 5634 "((a, b)\n=> a + b)(1, 2)",
5647 "((a, b)/*\n*/=> a + b)(1, 2)", 5635 "((a, b)/*\n*/=> a + b)(1, 2)",
5648 NULL}; 5636 NULL};
5649 static const ParserFlag always_flags[] = {kAllowHarmonyArrowFunctions}; 5637 static const ParserFlag always_flags[] = {kAllowHarmonyArrowFunctions};
5650 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, 5638 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags,
5651 arraysize(always_flags)); 5639 arraysize(always_flags));
5652 } 5640 }
OLDNEW
« no previous file with comments | « src/templates.js ('k') | test/js-perf-test/JSTests.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698