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

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

Issue 1926133003: Several tiny cleanups in test-parsing.cc (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 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 | « no previous file | 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 1487 matching lines...) Expand 10 before | Expand all | Expand 10 after
1498 arg_object = isolate->factory()->undefined_value(); 1498 arg_object = isolate->factory()->undefined_value();
1499 } 1499 }
1500 1500
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,
1509 kAllowHarmonyFunctionSent, 1508 kAllowHarmonyFunctionSent,
1510 kAllowHarmonyRestrictiveDeclarations, 1509 kAllowHarmonyRestrictiveDeclarations,
1511 kAllowHarmonyExponentiationOperator, 1510 kAllowHarmonyExponentiationOperator,
1512 kAllowHarmonyForIn 1511 kAllowHarmonyForIn
1513 }; 1512 };
1514 1513
1515 enum ParserSyncTestResult { 1514 enum ParserSyncTestResult {
1516 kSuccessOrError, 1515 kSuccessOrError,
1517 kSuccess, 1516 kSuccess,
1518 kError 1517 kError
(...skipping 3580 matching lines...) Expand 10 before | Expand all | Expand 10 after
5099 "`foo${a \n}`", 5098 "`foo${a \n}`",
5100 "`foo${a \r\n}`", 5099 "`foo${a \r\n}`",
5101 "`foo${a \r}`", 5100 "`foo${a \r}`",
5102 "`foo${/* comment */ a}`", 5101 "`foo${/* comment */ a}`",
5103 "`foo${// comment\na}`", 5102 "`foo${// comment\na}`",
5104 "`foo${\n a}`", 5103 "`foo${\n a}`",
5105 "`foo${\r\n a}`", 5104 "`foo${\r\n a}`",
5106 "`foo${\r a}`", 5105 "`foo${\r a}`",
5107 "`foo${'a' in a}`", 5106 "`foo${'a' in a}`",
5108 NULL}; 5107 NULL};
5109 RunParserSyncTest(context_data, data, kSuccess, NULL, 0, NULL, 0); 5108 RunParserSyncTest(context_data, data, kSuccess);
5110 } 5109 }
5111 5110
5112 5111
5113 TEST(ScanTaggedTemplateLiterals) { 5112 TEST(ScanTaggedTemplateLiterals) {
5114 const char* context_data[][2] = {{"'use strict';", ""}, 5113 const char* context_data[][2] = {{"'use strict';", ""},
5115 {"function foo(){ 'use strict';" 5114 {"function foo(){ 'use strict';"
5116 " function tag() {}" 5115 " function tag() {}"
5117 " var a, b, c; return ", "}"}, 5116 " var a, b, c; return ", "}"},
5118 {NULL, NULL}}; 5117 {NULL, NULL}};
5119 5118
(...skipping 14 matching lines...) Expand all
5134 "tag`foo${a \n}`", 5133 "tag`foo${a \n}`",
5135 "tag`foo${a \r\n}`", 5134 "tag`foo${a \r\n}`",
5136 "tag`foo${a \r}`", 5135 "tag`foo${a \r}`",
5137 "tag`foo${/* comment */ a}`", 5136 "tag`foo${/* comment */ a}`",
5138 "tag`foo${// comment\na}`", 5137 "tag`foo${// comment\na}`",
5139 "tag`foo${\n a}`", 5138 "tag`foo${\n a}`",
5140 "tag`foo${\r\n a}`", 5139 "tag`foo${\r\n a}`",
5141 "tag`foo${\r a}`", 5140 "tag`foo${\r a}`",
5142 "tag`foo${'a' in a}`", 5141 "tag`foo${'a' in a}`",
5143 NULL}; 5142 NULL};
5144 RunParserSyncTest(context_data, data, kSuccess, NULL, 0, NULL, 0); 5143 RunParserSyncTest(context_data, data, kSuccess);
5145 } 5144 }
5146 5145
5147 5146
5148 TEST(TemplateMaterializedLiterals) { 5147 TEST(TemplateMaterializedLiterals) {
5149 const char* context_data[][2] = { 5148 const char* context_data[][2] = {
5150 { 5149 {
5151 "'use strict';\n" 5150 "'use strict';\n"
5152 "function tag() {}\n" 5151 "function tag() {}\n"
5153 "var a, b, c;\n" 5152 "var a, b, c;\n"
5154 "(", ")" 5153 "(", ")"
5155 }, 5154 },
5156 {NULL, NULL} 5155 {NULL, NULL}
5157 }; 5156 };
5158 5157
5159 const char* data[] = { 5158 const char* data[] = {
5160 "tag``", 5159 "tag``",
5161 "tag`a`", 5160 "tag`a`",
5162 "tag`a${1}b`", 5161 "tag`a${1}b`",
5163 "tag`a${1}b${2}c`", 5162 "tag`a${1}b${2}c`",
5164 "``", 5163 "``",
5165 "`a`", 5164 "`a`",
5166 "`a${1}b`", 5165 "`a${1}b`",
5167 "`a${1}b${2}c`", 5166 "`a${1}b${2}c`",
5168 NULL 5167 NULL
5169 }; 5168 };
5170 5169
5171 RunParserSyncTest(context_data, data, kSuccess, NULL, 0, NULL, 0); 5170 RunParserSyncTest(context_data, data, kSuccess);
5172 } 5171 }
5173 5172
5174 5173
5175 TEST(ScanUnterminatedTemplateLiterals) { 5174 TEST(ScanUnterminatedTemplateLiterals) {
5176 const char* context_data[][2] = {{"'use strict';", ""}, 5175 const char* context_data[][2] = {{"'use strict';", ""},
5177 {"function foo(){ 'use strict';" 5176 {"function foo(){ 'use strict';"
5178 " var a, b, c; return ", "}"}, 5177 " var a, b, c; return ", "}"},
5179 {NULL, NULL}}; 5178 {NULL, NULL}};
5180 5179
5181 const char* data[] = { 5180 const char* data[] = {
(...skipping 13 matching lines...) Expand all
5195 "`foo${a \r\n`", 5194 "`foo${a \r\n`",
5196 "`foo${a \r`", 5195 "`foo${a \r`",
5197 "`foo${/* comment */ a`", 5196 "`foo${/* comment */ a`",
5198 "`foo${// commenta}`", 5197 "`foo${// commenta}`",
5199 "`foo${\n a`", 5198 "`foo${\n a`",
5200 "`foo${\r\n a`", 5199 "`foo${\r\n a`",
5201 "`foo${\r a`", 5200 "`foo${\r a`",
5202 "`foo${fn(}`", 5201 "`foo${fn(}`",
5203 "`foo${1 if}`", 5202 "`foo${1 if}`",
5204 NULL}; 5203 NULL};
5205 RunParserSyncTest(context_data, data, kError, NULL, 0, NULL, 0); 5204 RunParserSyncTest(context_data, data, kError);
5206 } 5205 }
5207 5206
5208 5207
5209 TEST(TemplateLiteralsIllegalTokens) { 5208 TEST(TemplateLiteralsIllegalTokens) {
5210 const char* context_data[][2] = {{"'use strict';", ""}, 5209 const char* context_data[][2] = {{"'use strict';", ""},
5211 {"function foo(){ 'use strict';" 5210 {"function foo(){ 'use strict';"
5212 " var a, b, c; return ", "}"}, 5211 " var a, b, c; return ", "}"},
5213 {NULL, NULL}}; 5212 {NULL, NULL}};
5214 const char* data[] = { 5213 const char* data[] = {
5215 "`hello\\x`", 5214 "`hello\\x`",
5216 "`hello\\x${1}`", 5215 "`hello\\x${1}`",
5217 "`hello${1}\\x`", 5216 "`hello${1}\\x`",
5218 "`hello${1}\\x${2}`", 5217 "`hello${1}\\x${2}`",
5219 "`hello\\x\n`", 5218 "`hello\\x\n`",
5220 "`hello\\x\n${1}`", 5219 "`hello\\x\n${1}`",
5221 "`hello${1}\\x\n`", 5220 "`hello${1}\\x\n`",
5222 "`hello${1}\\x\n${2}`", 5221 "`hello${1}\\x\n${2}`",
5223 NULL}; 5222 NULL};
5224 5223
5225 RunParserSyncTest(context_data, data, kError, NULL, 0, NULL, 0); 5224 RunParserSyncTest(context_data, data, kError);
5226 } 5225 }
5227 5226
5228 5227
5229 TEST(ParseRestParameters) { 5228 TEST(ParseRestParameters) {
5230 const char* context_data[][2] = {{"'use strict';(function(", 5229 const char* context_data[][2] = {{"'use strict';(function(",
5231 "){ return args;})(1, [], /regexp/, 'str'," 5230 "){ return args;})(1, [], /regexp/, 'str',"
5232 "function(){});"}, 5231 "function(){});"},
5233 {"(function(", "){ return args;})(1, []," 5232 {"(function(", "){ return args;})(1, [],"
5234 "/regexp/, 'str', function(){});"}, 5233 "/regexp/, 'str', function(){});"},
5235 {NULL, NULL}}; 5234 {NULL, NULL}};
(...skipping 1785 matching lines...) Expand 10 before | Expand all | Expand 10 after
7021 }; 7020 };
7022 const char* error_data[] = { 7021 const char* error_data[] = {
7023 "for (();;) {}", 7022 "for (();;) {}",
7024 7023
7025 // crbug.com/582626 7024 // crbug.com/582626
7026 "{ NaN ,chA((evarA=new t ( l = !.0[((... co -a0([1]))=> greturnkf", 7025 "{ NaN ,chA((evarA=new t ( l = !.0[((... co -a0([1]))=> greturnkf",
7027 NULL 7026 NULL
7028 }; 7027 };
7029 // clang-format on 7028 // clang-format on
7030 7029
7031 RunParserSyncTest(context_data, error_data, kError, NULL, 0, NULL, 0); 7030 RunParserSyncTest(context_data, error_data, kError);
7032 } 7031 }
7033 7032
7034 7033
7035 TEST(EscapeSequenceErrors) { 7034 TEST(EscapeSequenceErrors) {
7036 // clang-format off 7035 // clang-format off
7037 const char* context_data[][2] = { 7036 const char* context_data[][2] = {
7038 { "'", "'" }, 7037 { "'", "'" },
7039 { "\"", "\"" }, 7038 { "\"", "\"" },
7040 { "`", "`" }, 7039 { "`", "`" },
7041 { "`${'", "'}`" }, 7040 { "`${'", "'}`" },
7042 { "`${\"", "\"}`" }, 7041 { "`${\"", "\"}`" },
7043 { "`${`", "`}`" }, 7042 { "`${`", "`}`" },
7044 { "f(tag`", "`);" }, 7043 { "f(tag`", "`);" },
7045 { NULL, NULL } 7044 { NULL, NULL }
7046 }; 7045 };
7047 const char* error_data[] = { 7046 const char* error_data[] = {
7048 "\\uABCG", 7047 "\\uABCG",
7049 "\\u{ZZ}", 7048 "\\u{ZZ}",
7050 "\\u{FFZ}", 7049 "\\u{FFZ}",
7051 "\\u{FFFFFFFFFF }", 7050 "\\u{FFFFFFFFFF }",
7052 "\\u{110000}", 7051 "\\u{110000}",
7053 "\\u{110000", 7052 "\\u{110000",
7054 "\\u{FFFD }", 7053 "\\u{FFFD }",
7055 "\\xZF", 7054 "\\xZF",
7056 NULL 7055 NULL
7057 }; 7056 };
7058 // clang-format on 7057 // clang-format on
7059 7058
7060 RunParserSyncTest(context_data, error_data, kError, NULL, 0, NULL, 0); 7059 RunParserSyncTest(context_data, error_data, kError);
7061 } 7060 }
7062 7061
7063 7062
7064 TEST(FunctionSentErrors) { 7063 TEST(FunctionSentErrors) {
7065 // clang-format off 7064 // clang-format off
7066 const char* context_data[][2] = { 7065 const char* context_data[][2] = {
7067 { "'use strict'", "" }, 7066 { "'use strict'", "" },
7068 { "", "" }, 7067 { "", "" },
7069 { NULL, NULL } 7068 { NULL, NULL }
7070 }; 7069 };
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
7293 "for (const x = 0 in {});", 7292 "for (const x = 0 in {});",
7294 "for (let x = 0 in {});", 7293 "for (let x = 0 in {});",
7295 NULL 7294 NULL
7296 }; 7295 };
7297 // clang-format on 7296 // clang-format on
7298 7297
7299 static const ParserFlag always_flags[] = {kAllowHarmonyForIn}; 7298 static const ParserFlag always_flags[] = {kAllowHarmonyForIn};
7300 RunParserSyncTest(context_data, error_data, kError, nullptr, 0, always_flags, 7299 RunParserSyncTest(context_data, error_data, kError, nullptr, 0, always_flags,
7301 arraysize(always_flags)); 7300 arraysize(always_flags));
7302 } 7301 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698