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

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

Issue 1801203002: Parser: Make skipping HTML comments optional. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase. Created 4 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 | « test/cctest/test-api.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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 KeywordToken key_token; 63 KeywordToken key_token;
64 i::UnicodeCache unicode_cache; 64 i::UnicodeCache unicode_cache;
65 i::byte buffer[32]; 65 i::byte buffer[32];
66 for (int i = 0; (key_token = keywords[i]).keyword != NULL; i++) { 66 for (int i = 0; (key_token = keywords[i]).keyword != NULL; i++) {
67 const i::byte* keyword = 67 const i::byte* keyword =
68 reinterpret_cast<const i::byte*>(key_token.keyword); 68 reinterpret_cast<const i::byte*>(key_token.keyword);
69 int length = i::StrLength(key_token.keyword); 69 int length = i::StrLength(key_token.keyword);
70 CHECK(static_cast<int>(sizeof(buffer)) >= length); 70 CHECK(static_cast<int>(sizeof(buffer)) >= length);
71 { 71 {
72 i::Utf8ToUtf16CharacterStream stream(keyword, length); 72 i::Utf8ToUtf16CharacterStream stream(keyword, length);
73 i::Scanner scanner(&unicode_cache); 73 i::Scanner scanner(&unicode_cache, false);
74 scanner.Initialize(&stream); 74 scanner.Initialize(&stream);
75 CHECK_EQ(key_token.token, scanner.Next()); 75 CHECK_EQ(key_token.token, scanner.Next());
76 CHECK_EQ(i::Token::EOS, scanner.Next()); 76 CHECK_EQ(i::Token::EOS, scanner.Next());
77 } 77 }
78 // Removing characters will make keyword matching fail. 78 // Removing characters will make keyword matching fail.
79 { 79 {
80 i::Utf8ToUtf16CharacterStream stream(keyword, length - 1); 80 i::Utf8ToUtf16CharacterStream stream(keyword, length - 1);
81 i::Scanner scanner(&unicode_cache); 81 i::Scanner scanner(&unicode_cache, false);
82 scanner.Initialize(&stream); 82 scanner.Initialize(&stream);
83 CHECK_EQ(i::Token::IDENTIFIER, scanner.Next()); 83 CHECK_EQ(i::Token::IDENTIFIER, scanner.Next());
84 CHECK_EQ(i::Token::EOS, scanner.Next()); 84 CHECK_EQ(i::Token::EOS, scanner.Next());
85 } 85 }
86 // Adding characters will make keyword matching fail. 86 // Adding characters will make keyword matching fail.
87 static const char chars_to_append[] = { 'z', '0', '_' }; 87 static const char chars_to_append[] = { 'z', '0', '_' };
88 for (int j = 0; j < static_cast<int>(arraysize(chars_to_append)); ++j) { 88 for (int j = 0; j < static_cast<int>(arraysize(chars_to_append)); ++j) {
89 i::MemMove(buffer, keyword, length); 89 i::MemMove(buffer, keyword, length);
90 buffer[length] = chars_to_append[j]; 90 buffer[length] = chars_to_append[j];
91 i::Utf8ToUtf16CharacterStream stream(buffer, length + 1); 91 i::Utf8ToUtf16CharacterStream stream(buffer, length + 1);
92 i::Scanner scanner(&unicode_cache); 92 i::Scanner scanner(&unicode_cache, false);
93 scanner.Initialize(&stream); 93 scanner.Initialize(&stream);
94 CHECK_EQ(i::Token::IDENTIFIER, scanner.Next()); 94 CHECK_EQ(i::Token::IDENTIFIER, scanner.Next());
95 CHECK_EQ(i::Token::EOS, scanner.Next()); 95 CHECK_EQ(i::Token::EOS, scanner.Next());
96 } 96 }
97 // Replacing characters will make keyword matching fail. 97 // Replacing characters will make keyword matching fail.
98 { 98 {
99 i::MemMove(buffer, keyword, length); 99 i::MemMove(buffer, keyword, length);
100 buffer[length - 1] = '_'; 100 buffer[length - 1] = '_';
101 i::Utf8ToUtf16CharacterStream stream(buffer, length); 101 i::Utf8ToUtf16CharacterStream stream(buffer, length);
102 i::Scanner scanner(&unicode_cache); 102 i::Scanner scanner(&unicode_cache, false);
103 scanner.Initialize(&stream); 103 scanner.Initialize(&stream);
104 CHECK_EQ(i::Token::IDENTIFIER, scanner.Next()); 104 CHECK_EQ(i::Token::IDENTIFIER, scanner.Next());
105 CHECK_EQ(i::Token::EOS, scanner.Next()); 105 CHECK_EQ(i::Token::EOS, scanner.Next());
106 } 106 }
107 } 107 }
108 } 108 }
109 109
110 110
111 TEST(ScanHTMLEndComments) { 111 TEST(ScanHTMLEndComments) {
112 v8::V8::Initialize(); 112 v8::V8::Initialize();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 144
145 // Parser/Scanner needs a stack limit. 145 // Parser/Scanner needs a stack limit.
146 CcTest::i_isolate()->stack_guard()->SetStackLimit( 146 CcTest::i_isolate()->stack_guard()->SetStackLimit(
147 i::GetCurrentStackPosition() - 128 * 1024); 147 i::GetCurrentStackPosition() - 128 * 1024);
148 uintptr_t stack_limit = CcTest::i_isolate()->stack_guard()->real_climit(); 148 uintptr_t stack_limit = CcTest::i_isolate()->stack_guard()->real_climit();
149 for (int i = 0; tests[i]; i++) { 149 for (int i = 0; tests[i]; i++) {
150 const i::byte* source = 150 const i::byte* source =
151 reinterpret_cast<const i::byte*>(tests[i]); 151 reinterpret_cast<const i::byte*>(tests[i]);
152 i::Utf8ToUtf16CharacterStream stream(source, i::StrLength(tests[i])); 152 i::Utf8ToUtf16CharacterStream stream(source, i::StrLength(tests[i]));
153 i::CompleteParserRecorder log; 153 i::CompleteParserRecorder log;
154 i::Scanner scanner(CcTest::i_isolate()->unicode_cache()); 154 i::Scanner scanner(CcTest::i_isolate()->unicode_cache(), false);
155 scanner.Initialize(&stream); 155 scanner.Initialize(&stream);
156 i::Zone zone; 156 i::Zone zone;
157 i::AstValueFactory ast_value_factory( 157 i::AstValueFactory ast_value_factory(
158 &zone, CcTest::i_isolate()->heap()->HashSeed()); 158 &zone, CcTest::i_isolate()->heap()->HashSeed());
159 i::PreParser preparser(&zone, &scanner, &ast_value_factory, &log, 159 i::PreParser preparser(&zone, &scanner, &ast_value_factory, &log,
160 stack_limit); 160 stack_limit);
161 preparser.set_allow_lazy(true); 161 preparser.set_allow_lazy(true);
162 i::PreParser::PreParseResult result = preparser.PreParseProgram(); 162 i::PreParser::PreParseResult result = preparser.PreParseProgram();
163 CHECK_EQ(i::PreParser::kPreParseSuccess, result); 163 CHECK_EQ(i::PreParser::kPreParseSuccess, result);
164 CHECK(!log.HasError()); 164 CHECK(!log.HasError());
165 } 165 }
166 166
167 for (int i = 0; fail_tests[i]; i++) { 167 for (int i = 0; fail_tests[i]; i++) {
168 const i::byte* source = 168 const i::byte* source =
169 reinterpret_cast<const i::byte*>(fail_tests[i]); 169 reinterpret_cast<const i::byte*>(fail_tests[i]);
170 i::Utf8ToUtf16CharacterStream stream(source, i::StrLength(fail_tests[i])); 170 i::Utf8ToUtf16CharacterStream stream(source, i::StrLength(fail_tests[i]));
171 i::CompleteParserRecorder log; 171 i::CompleteParserRecorder log;
172 i::Scanner scanner(CcTest::i_isolate()->unicode_cache()); 172 i::Scanner scanner(CcTest::i_isolate()->unicode_cache(), false);
173 scanner.Initialize(&stream); 173 scanner.Initialize(&stream);
174 i::Zone zone; 174 i::Zone zone;
175 i::AstValueFactory ast_value_factory( 175 i::AstValueFactory ast_value_factory(
176 &zone, CcTest::i_isolate()->heap()->HashSeed()); 176 &zone, CcTest::i_isolate()->heap()->HashSeed());
177 i::PreParser preparser(&zone, &scanner, &ast_value_factory, &log, 177 i::PreParser preparser(&zone, &scanner, &ast_value_factory, &log,
178 stack_limit); 178 stack_limit);
179 preparser.set_allow_lazy(true); 179 preparser.set_allow_lazy(true);
180 i::PreParser::PreParseResult result = preparser.PreParseProgram(); 180 i::PreParser::PreParseResult result = preparser.PreParseProgram();
181 // Even in the case of a syntax error, kPreParseSuccess is returned. 181 // Even in the case of a syntax error, kPreParseSuccess is returned.
182 CHECK_EQ(i::PreParser::kPreParseSuccess, result); 182 CHECK_EQ(i::PreParser::kPreParseSuccess, result);
183 CHECK(log.HasError()); 183 CHECK(log.HasError());
184 } 184 }
185 } 185 }
186 186
187 TEST(ScanHtmlComments) {
188 const char* src = "a <!-- b --> c";
189 i::UnicodeCache unicode_cache;
190
191 // Skip HTML comments:
192 {
193 i::Utf8ToUtf16CharacterStream stream(reinterpret_cast<const i::byte*>(src),
194 i::StrLength(src));
195 i::Scanner scanner(&unicode_cache, true);
196 scanner.Initialize(&stream);
197 CHECK_EQ(i::Token::IDENTIFIER, scanner.Next());
198 CHECK_EQ(i::Token::EOS, scanner.Next());
199 }
200
201 // Parse (don't skip) HTML comments:
202 {
203 i::Utf8ToUtf16CharacterStream stream(reinterpret_cast<const i::byte*>(src),
204 i::StrLength(src));
205 i::Scanner scanner(&unicode_cache, false);
206 scanner.Initialize(&stream);
207 CHECK_EQ(i::Token::IDENTIFIER, scanner.Next());
208 CHECK_EQ(i::Token::LT, scanner.Next());
209 CHECK_EQ(i::Token::NOT, scanner.Next());
210 CHECK_EQ(i::Token::DEC, scanner.Next());
211 }
212 }
187 213
188 class ScriptResource : public v8::String::ExternalOneByteStringResource { 214 class ScriptResource : public v8::String::ExternalOneByteStringResource {
189 public: 215 public:
190 ScriptResource(const char* data, size_t length) 216 ScriptResource(const char* data, size_t length)
191 : data_(data), length_(length) { } 217 : data_(data), length_(length) { }
192 218
193 const char* data() const { return data_; } 219 const char* data() const { return data_; }
194 size_t length() const { return length_; } 220 size_t length() const { return length_; }
195 221
196 private: 222 private:
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 NULL 342 NULL
317 }; 343 };
318 344
319 uintptr_t stack_limit = CcTest::i_isolate()->stack_guard()->real_climit(); 345 uintptr_t stack_limit = CcTest::i_isolate()->stack_guard()->real_climit();
320 for (int i = 0; programs[i]; i++) { 346 for (int i = 0; programs[i]; i++) {
321 const char* program = programs[i]; 347 const char* program = programs[i];
322 i::Utf8ToUtf16CharacterStream stream( 348 i::Utf8ToUtf16CharacterStream stream(
323 reinterpret_cast<const i::byte*>(program), 349 reinterpret_cast<const i::byte*>(program),
324 static_cast<unsigned>(strlen(program))); 350 static_cast<unsigned>(strlen(program)));
325 i::CompleteParserRecorder log; 351 i::CompleteParserRecorder log;
326 i::Scanner scanner(CcTest::i_isolate()->unicode_cache()); 352 i::Scanner scanner(CcTest::i_isolate()->unicode_cache(), false);
327 scanner.Initialize(&stream); 353 scanner.Initialize(&stream);
328 354
329 i::Zone zone; 355 i::Zone zone;
330 i::AstValueFactory ast_value_factory( 356 i::AstValueFactory ast_value_factory(
331 &zone, CcTest::i_isolate()->heap()->HashSeed()); 357 &zone, CcTest::i_isolate()->heap()->HashSeed());
332 i::PreParser preparser(&zone, &scanner, &ast_value_factory, &log, 358 i::PreParser preparser(&zone, &scanner, &ast_value_factory, &log,
333 stack_limit); 359 stack_limit);
334 preparser.set_allow_lazy(true); 360 preparser.set_allow_lazy(true);
335 preparser.set_allow_natives(true); 361 preparser.set_allow_natives(true);
336 i::PreParser::PreParseResult result = preparser.PreParseProgram(); 362 i::PreParser::PreParseResult result = preparser.PreParseProgram();
(...skipping 15 matching lines...) Expand all
352 NULL 378 NULL
353 }; 379 };
354 380
355 uintptr_t stack_limit = CcTest::i_isolate()->stack_guard()->real_climit(); 381 uintptr_t stack_limit = CcTest::i_isolate()->stack_guard()->real_climit();
356 for (int i = 0; programs[i]; i++) { 382 for (int i = 0; programs[i]; i++) {
357 const char* program = programs[i]; 383 const char* program = programs[i];
358 i::Utf8ToUtf16CharacterStream stream( 384 i::Utf8ToUtf16CharacterStream stream(
359 reinterpret_cast<const i::byte*>(program), 385 reinterpret_cast<const i::byte*>(program),
360 static_cast<unsigned>(strlen(program))); 386 static_cast<unsigned>(strlen(program)));
361 i::CompleteParserRecorder log; 387 i::CompleteParserRecorder log;
362 i::Scanner scanner(CcTest::i_isolate()->unicode_cache()); 388 i::Scanner scanner(CcTest::i_isolate()->unicode_cache(), false);
363 scanner.Initialize(&stream); 389 scanner.Initialize(&stream);
364 390
365 // Preparser defaults to disallowing natives syntax. 391 // Preparser defaults to disallowing natives syntax.
366 i::Zone zone; 392 i::Zone zone;
367 i::AstValueFactory ast_value_factory( 393 i::AstValueFactory ast_value_factory(
368 &zone, CcTest::i_isolate()->heap()->HashSeed()); 394 &zone, CcTest::i_isolate()->heap()->HashSeed());
369 i::PreParser preparser(&zone, &scanner, &ast_value_factory, &log, 395 i::PreParser preparser(&zone, &scanner, &ast_value_factory, &log,
370 stack_limit); 396 stack_limit);
371 preparser.set_allow_lazy(true); 397 preparser.set_allow_lazy(true);
372 i::PreParser::PreParseResult result = preparser.PreParseProgram(); 398 i::PreParser::PreParseResult result = preparser.PreParseProgram();
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 "escape: function() {}"; 449 "escape: function() {}";
424 // Fails parsing expecting an identifier after "function". 450 // Fails parsing expecting an identifier after "function".
425 // Before fix, didn't check *ok after Expect(Token::Identifier, ok), 451 // Before fix, didn't check *ok after Expect(Token::Identifier, ok),
426 // and then used the invalid currently scanned literal. This always 452 // and then used the invalid currently scanned literal. This always
427 // failed in debug mode, and sometimes crashed in release mode. 453 // failed in debug mode, and sometimes crashed in release mode.
428 454
429 i::Utf8ToUtf16CharacterStream stream( 455 i::Utf8ToUtf16CharacterStream stream(
430 reinterpret_cast<const i::byte*>(program), 456 reinterpret_cast<const i::byte*>(program),
431 static_cast<unsigned>(strlen(program))); 457 static_cast<unsigned>(strlen(program)));
432 i::CompleteParserRecorder log; 458 i::CompleteParserRecorder log;
433 i::Scanner scanner(CcTest::i_isolate()->unicode_cache()); 459 i::Scanner scanner(CcTest::i_isolate()->unicode_cache(), false);
434 scanner.Initialize(&stream); 460 scanner.Initialize(&stream);
435 i::Zone zone; 461 i::Zone zone;
436 i::AstValueFactory ast_value_factory(&zone, 462 i::AstValueFactory ast_value_factory(&zone,
437 CcTest::i_isolate()->heap()->HashSeed()); 463 CcTest::i_isolate()->heap()->HashSeed());
438 i::PreParser preparser(&zone, &scanner, &ast_value_factory, &log, 464 i::PreParser preparser(&zone, &scanner, &ast_value_factory, &log,
439 CcTest::i_isolate()->stack_guard()->real_climit()); 465 CcTest::i_isolate()->stack_guard()->real_climit());
440 preparser.set_allow_lazy(true); 466 preparser.set_allow_lazy(true);
441 i::PreParser::PreParseResult result = preparser.PreParseProgram(); 467 i::PreParser::PreParseResult result = preparser.PreParseProgram();
442 // Even in the case of a syntax error, kPreParseSuccess is returned. 468 // Even in the case of a syntax error, kPreParseSuccess is returned.
443 CHECK_EQ(i::PreParser::kPreParseSuccess, result); 469 CHECK_EQ(i::PreParser::kPreParseSuccess, result);
(...skipping 14 matching lines...) Expand all
458 128 * 1024); 484 128 * 1024);
459 485
460 const char* program = 486 const char* program =
461 "try { } catch (e) { var foo = function () { /* first */ } }" 487 "try { } catch (e) { var foo = function () { /* first */ } }"
462 "var bar = function () { /* second */ }"; 488 "var bar = function () { /* second */ }";
463 489
464 v8::HandleScope handles(CcTest::isolate()); 490 v8::HandleScope handles(CcTest::isolate());
465 i::Handle<i::String> source = factory->NewStringFromAsciiChecked(program); 491 i::Handle<i::String> source = factory->NewStringFromAsciiChecked(program);
466 i::GenericStringUtf16CharacterStream stream(source, 0, source->length()); 492 i::GenericStringUtf16CharacterStream stream(source, 0, source->length());
467 i::CompleteParserRecorder log; 493 i::CompleteParserRecorder log;
468 i::Scanner scanner(CcTest::i_isolate()->unicode_cache()); 494 i::Scanner scanner(CcTest::i_isolate()->unicode_cache(), false);
469 scanner.Initialize(&stream); 495 scanner.Initialize(&stream);
470 i::Zone zone; 496 i::Zone zone;
471 i::AstValueFactory ast_value_factory(&zone, 497 i::AstValueFactory ast_value_factory(&zone,
472 CcTest::i_isolate()->heap()->HashSeed()); 498 CcTest::i_isolate()->heap()->HashSeed());
473 i::PreParser preparser(&zone, &scanner, &ast_value_factory, &log, 499 i::PreParser preparser(&zone, &scanner, &ast_value_factory, &log,
474 CcTest::i_isolate()->stack_guard()->real_climit()); 500 CcTest::i_isolate()->stack_guard()->real_climit());
475 preparser.set_allow_lazy(true); 501 preparser.set_allow_lazy(true);
476 i::PreParser::PreParseResult result = preparser.PreParseProgram(); 502 i::PreParser::PreParseResult result = preparser.PreParseProgram();
477 CHECK_EQ(i::PreParser::kPreParseSuccess, result); 503 CHECK_EQ(i::PreParser::kPreParseSuccess, result);
478 i::ScriptData* sd = log.GetScriptData(); 504 i::ScriptData* sd = log.GetScriptData();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 i::NewArray<char>(kProgramSize + 1)); 536 i::NewArray<char>(kProgramSize + 1));
511 memset(program.get(), '(', kProgramSize); 537 memset(program.get(), '(', kProgramSize);
512 program[kProgramSize] = '\0'; 538 program[kProgramSize] = '\0';
513 539
514 uintptr_t stack_limit = CcTest::i_isolate()->stack_guard()->real_climit(); 540 uintptr_t stack_limit = CcTest::i_isolate()->stack_guard()->real_climit();
515 541
516 i::Utf8ToUtf16CharacterStream stream( 542 i::Utf8ToUtf16CharacterStream stream(
517 reinterpret_cast<const i::byte*>(program.get()), 543 reinterpret_cast<const i::byte*>(program.get()),
518 static_cast<unsigned>(kProgramSize)); 544 static_cast<unsigned>(kProgramSize));
519 i::CompleteParserRecorder log; 545 i::CompleteParserRecorder log;
520 i::Scanner scanner(CcTest::i_isolate()->unicode_cache()); 546 i::Scanner scanner(CcTest::i_isolate()->unicode_cache(), false);
521 scanner.Initialize(&stream); 547 scanner.Initialize(&stream);
522 548
523 i::Zone zone; 549 i::Zone zone;
524 i::AstValueFactory ast_value_factory(&zone, 550 i::AstValueFactory ast_value_factory(&zone,
525 CcTest::i_isolate()->heap()->HashSeed()); 551 CcTest::i_isolate()->heap()->HashSeed());
526 i::PreParser preparser(&zone, &scanner, &ast_value_factory, &log, 552 i::PreParser preparser(&zone, &scanner, &ast_value_factory, &log,
527 stack_limit); 553 stack_limit);
528 preparser.set_allow_lazy(true); 554 preparser.set_allow_lazy(true);
529 i::PreParser::PreParseResult result = preparser.PreParseProgram(); 555 i::PreParser::PreParseResult result = preparser.PreParseProgram();
530 CHECK_EQ(i::PreParser::kPreParseStackOverflow, result); 556 CHECK_EQ(i::PreParser::kPreParseStackOverflow, result);
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 CHECK_EQU(i, stream.pos()); 766 CHECK_EQU(i, stream.pos());
741 } 767 }
742 } 768 }
743 769
744 #undef CHECK_EQU 770 #undef CHECK_EQU
745 771
746 void TestStreamScanner(i::Utf16CharacterStream* stream, 772 void TestStreamScanner(i::Utf16CharacterStream* stream,
747 i::Token::Value* expected_tokens, 773 i::Token::Value* expected_tokens,
748 int skip_pos = 0, // Zero means not skipping. 774 int skip_pos = 0, // Zero means not skipping.
749 int skip_to = 0) { 775 int skip_to = 0) {
750 i::Scanner scanner(CcTest::i_isolate()->unicode_cache()); 776 i::Scanner scanner(CcTest::i_isolate()->unicode_cache(), false);
751 scanner.Initialize(stream); 777 scanner.Initialize(stream);
752 778
753 int i = 0; 779 int i = 0;
754 do { 780 do {
755 i::Token::Value expected = expected_tokens[i]; 781 i::Token::Value expected = expected_tokens[i];
756 i::Token::Value actual = scanner.Next(); 782 i::Token::Value actual = scanner.Next();
757 CHECK_EQ(i::Token::String(expected), i::Token::String(actual)); 783 CHECK_EQ(i::Token::String(expected), i::Token::String(actual));
758 if (scanner.location().end_pos == skip_pos) { 784 if (scanner.location().end_pos == skip_pos) {
759 scanner.SeekForward(skip_to); 785 scanner.SeekForward(skip_to);
760 } 786 }
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
823 TestStreamScanner(&stream3, expectations3, 1, 1 + i); 849 TestStreamScanner(&stream3, expectations3, 1, 1 + i);
824 } 850 }
825 } 851 }
826 852
827 853
828 void TestScanRegExp(const char* re_source, const char* expected) { 854 void TestScanRegExp(const char* re_source, const char* expected) {
829 i::Utf8ToUtf16CharacterStream stream( 855 i::Utf8ToUtf16CharacterStream stream(
830 reinterpret_cast<const i::byte*>(re_source), 856 reinterpret_cast<const i::byte*>(re_source),
831 static_cast<unsigned>(strlen(re_source))); 857 static_cast<unsigned>(strlen(re_source)));
832 i::HandleScope scope(CcTest::i_isolate()); 858 i::HandleScope scope(CcTest::i_isolate());
833 i::Scanner scanner(CcTest::i_isolate()->unicode_cache()); 859 i::Scanner scanner(CcTest::i_isolate()->unicode_cache(), false);
834 scanner.Initialize(&stream); 860 scanner.Initialize(&stream);
835 861
836 i::Token::Value start = scanner.peek(); 862 i::Token::Value start = scanner.peek();
837 CHECK(start == i::Token::DIV || start == i::Token::ASSIGN_DIV); 863 CHECK(start == i::Token::DIV || start == i::Token::ASSIGN_DIV);
838 CHECK(scanner.ScanRegExpPattern(start == i::Token::ASSIGN_DIV)); 864 CHECK(scanner.ScanRegExpPattern(start == i::Token::ASSIGN_DIV));
839 scanner.Next(); // Current token is now the regexp literal. 865 scanner.Next(); // Current token is now the regexp literal.
840 i::Zone zone; 866 i::Zone zone;
841 i::AstValueFactory ast_value_factory(&zone, 867 i::AstValueFactory ast_value_factory(&zone,
842 CcTest::i_isolate()->heap()->HashSeed()); 868 CcTest::i_isolate()->heap()->HashSeed());
843 ast_value_factory.Internalize(CcTest::i_isolate()); 869 ast_value_factory.Internalize(CcTest::i_isolate());
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after
1543 i::Factory* factory = isolate->factory(); 1569 i::Factory* factory = isolate->factory();
1544 1570
1545 uintptr_t stack_limit = isolate->stack_guard()->real_climit(); 1571 uintptr_t stack_limit = isolate->stack_guard()->real_climit();
1546 int preparser_materialized_literals = -1; 1572 int preparser_materialized_literals = -1;
1547 int parser_materialized_literals = -2; 1573 int parser_materialized_literals = -2;
1548 bool test_preparser = !is_module; 1574 bool test_preparser = !is_module;
1549 1575
1550 // Preparse the data. 1576 // Preparse the data.
1551 i::CompleteParserRecorder log; 1577 i::CompleteParserRecorder log;
1552 if (test_preparser) { 1578 if (test_preparser) {
1553 i::Scanner scanner(isolate->unicode_cache()); 1579 i::Scanner scanner(isolate->unicode_cache(), false);
1554 i::GenericStringUtf16CharacterStream stream(source, 0, source->length()); 1580 i::GenericStringUtf16CharacterStream stream(source, 0, source->length());
1555 i::Zone zone; 1581 i::Zone zone;
1556 i::AstValueFactory ast_value_factory( 1582 i::AstValueFactory ast_value_factory(
1557 &zone, CcTest::i_isolate()->heap()->HashSeed()); 1583 &zone, CcTest::i_isolate()->heap()->HashSeed());
1558 i::PreParser preparser(&zone, &scanner, &ast_value_factory, &log, 1584 i::PreParser preparser(&zone, &scanner, &ast_value_factory, &log,
1559 stack_limit); 1585 stack_limit);
1560 SetParserFlags(&preparser, flags); 1586 SetParserFlags(&preparser, flags);
1561 scanner.Initialize(&stream); 1587 scanner.Initialize(&stream);
1562 i::PreParser::PreParseResult result = preparser.PreParseProgram( 1588 i::PreParser::PreParseResult result = preparser.PreParseProgram(
1563 &preparser_materialized_literals); 1589 &preparser_materialized_literals);
(...skipping 5846 matching lines...) Expand 10 before | Expand all | Expand 10 after
7410 // "Array() **= 10", 7436 // "Array() **= 10",
7411 NULL 7437 NULL
7412 }; 7438 };
7413 // clang-format on 7439 // clang-format on
7414 7440
7415 static const ParserFlag always_flags[] = { 7441 static const ParserFlag always_flags[] = {
7416 kAllowHarmonyExponentiationOperator}; 7442 kAllowHarmonyExponentiationOperator};
7417 RunParserSyncTest(context_data, error_data, kError, NULL, 0, always_flags, 7443 RunParserSyncTest(context_data, error_data, kError, NULL, 0, always_flags,
7418 arraysize(always_flags)); 7444 arraysize(always_flags));
7419 } 7445 }
OLDNEW
« no previous file with comments | « test/cctest/test-api.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698