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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/cctest/test-api.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-parsing.cc
diff --git a/test/cctest/test-parsing.cc b/test/cctest/test-parsing.cc
index 276cc86bd340ef4485c721a644be9f36b640afcf..d8e2aaed6cfe22f22018c64a2a66593d7433e8e1 100644
--- a/test/cctest/test-parsing.cc
+++ b/test/cctest/test-parsing.cc
@@ -70,7 +70,7 @@ TEST(ScanKeywords) {
CHECK(static_cast<int>(sizeof(buffer)) >= length);
{
i::Utf8ToUtf16CharacterStream stream(keyword, length);
- i::Scanner scanner(&unicode_cache);
+ i::Scanner scanner(&unicode_cache, false);
scanner.Initialize(&stream);
CHECK_EQ(key_token.token, scanner.Next());
CHECK_EQ(i::Token::EOS, scanner.Next());
@@ -78,7 +78,7 @@ TEST(ScanKeywords) {
// Removing characters will make keyword matching fail.
{
i::Utf8ToUtf16CharacterStream stream(keyword, length - 1);
- i::Scanner scanner(&unicode_cache);
+ i::Scanner scanner(&unicode_cache, false);
scanner.Initialize(&stream);
CHECK_EQ(i::Token::IDENTIFIER, scanner.Next());
CHECK_EQ(i::Token::EOS, scanner.Next());
@@ -89,7 +89,7 @@ TEST(ScanKeywords) {
i::MemMove(buffer, keyword, length);
buffer[length] = chars_to_append[j];
i::Utf8ToUtf16CharacterStream stream(buffer, length + 1);
- i::Scanner scanner(&unicode_cache);
+ i::Scanner scanner(&unicode_cache, false);
scanner.Initialize(&stream);
CHECK_EQ(i::Token::IDENTIFIER, scanner.Next());
CHECK_EQ(i::Token::EOS, scanner.Next());
@@ -99,7 +99,7 @@ TEST(ScanKeywords) {
i::MemMove(buffer, keyword, length);
buffer[length - 1] = '_';
i::Utf8ToUtf16CharacterStream stream(buffer, length);
- i::Scanner scanner(&unicode_cache);
+ i::Scanner scanner(&unicode_cache, false);
scanner.Initialize(&stream);
CHECK_EQ(i::Token::IDENTIFIER, scanner.Next());
CHECK_EQ(i::Token::EOS, scanner.Next());
@@ -151,7 +151,7 @@ TEST(ScanHTMLEndComments) {
reinterpret_cast<const i::byte*>(tests[i]);
i::Utf8ToUtf16CharacterStream stream(source, i::StrLength(tests[i]));
i::CompleteParserRecorder log;
- i::Scanner scanner(CcTest::i_isolate()->unicode_cache());
+ i::Scanner scanner(CcTest::i_isolate()->unicode_cache(), false);
scanner.Initialize(&stream);
i::Zone zone;
i::AstValueFactory ast_value_factory(
@@ -169,7 +169,7 @@ TEST(ScanHTMLEndComments) {
reinterpret_cast<const i::byte*>(fail_tests[i]);
i::Utf8ToUtf16CharacterStream stream(source, i::StrLength(fail_tests[i]));
i::CompleteParserRecorder log;
- i::Scanner scanner(CcTest::i_isolate()->unicode_cache());
+ i::Scanner scanner(CcTest::i_isolate()->unicode_cache(), false);
scanner.Initialize(&stream);
i::Zone zone;
i::AstValueFactory ast_value_factory(
@@ -184,6 +184,32 @@ TEST(ScanHTMLEndComments) {
}
}
+TEST(ScanHtmlComments) {
+ const char* src = "a <!-- b --> c";
+ i::UnicodeCache unicode_cache;
+
+ // Skip HTML comments:
+ {
+ i::Utf8ToUtf16CharacterStream stream(reinterpret_cast<const i::byte*>(src),
+ i::StrLength(src));
+ i::Scanner scanner(&unicode_cache, true);
+ scanner.Initialize(&stream);
+ CHECK_EQ(i::Token::IDENTIFIER, scanner.Next());
+ CHECK_EQ(i::Token::EOS, scanner.Next());
+ }
+
+ // Parse (don't skip) HTML comments:
+ {
+ i::Utf8ToUtf16CharacterStream stream(reinterpret_cast<const i::byte*>(src),
+ i::StrLength(src));
+ i::Scanner scanner(&unicode_cache, false);
+ scanner.Initialize(&stream);
+ CHECK_EQ(i::Token::IDENTIFIER, scanner.Next());
+ CHECK_EQ(i::Token::LT, scanner.Next());
+ CHECK_EQ(i::Token::NOT, scanner.Next());
+ CHECK_EQ(i::Token::DEC, scanner.Next());
+ }
+}
class ScriptResource : public v8::String::ExternalOneByteStringResource {
public:
@@ -323,7 +349,7 @@ TEST(StandAlonePreParser) {
reinterpret_cast<const i::byte*>(program),
static_cast<unsigned>(strlen(program)));
i::CompleteParserRecorder log;
- i::Scanner scanner(CcTest::i_isolate()->unicode_cache());
+ i::Scanner scanner(CcTest::i_isolate()->unicode_cache(), false);
scanner.Initialize(&stream);
i::Zone zone;
@@ -359,7 +385,7 @@ TEST(StandAlonePreParserNoNatives) {
reinterpret_cast<const i::byte*>(program),
static_cast<unsigned>(strlen(program)));
i::CompleteParserRecorder log;
- i::Scanner scanner(CcTest::i_isolate()->unicode_cache());
+ i::Scanner scanner(CcTest::i_isolate()->unicode_cache(), false);
scanner.Initialize(&stream);
// Preparser defaults to disallowing natives syntax.
@@ -430,7 +456,7 @@ TEST(RegressChromium62639) {
reinterpret_cast<const i::byte*>(program),
static_cast<unsigned>(strlen(program)));
i::CompleteParserRecorder log;
- i::Scanner scanner(CcTest::i_isolate()->unicode_cache());
+ i::Scanner scanner(CcTest::i_isolate()->unicode_cache(), false);
scanner.Initialize(&stream);
i::Zone zone;
i::AstValueFactory ast_value_factory(&zone,
@@ -465,7 +491,7 @@ TEST(Regress928) {
i::Handle<i::String> source = factory->NewStringFromAsciiChecked(program);
i::GenericStringUtf16CharacterStream stream(source, 0, source->length());
i::CompleteParserRecorder log;
- i::Scanner scanner(CcTest::i_isolate()->unicode_cache());
+ i::Scanner scanner(CcTest::i_isolate()->unicode_cache(), false);
scanner.Initialize(&stream);
i::Zone zone;
i::AstValueFactory ast_value_factory(&zone,
@@ -517,7 +543,7 @@ TEST(PreParseOverflow) {
reinterpret_cast<const i::byte*>(program.get()),
static_cast<unsigned>(kProgramSize));
i::CompleteParserRecorder log;
- i::Scanner scanner(CcTest::i_isolate()->unicode_cache());
+ i::Scanner scanner(CcTest::i_isolate()->unicode_cache(), false);
scanner.Initialize(&stream);
i::Zone zone;
@@ -747,7 +773,7 @@ void TestStreamScanner(i::Utf16CharacterStream* stream,
i::Token::Value* expected_tokens,
int skip_pos = 0, // Zero means not skipping.
int skip_to = 0) {
- i::Scanner scanner(CcTest::i_isolate()->unicode_cache());
+ i::Scanner scanner(CcTest::i_isolate()->unicode_cache(), false);
scanner.Initialize(stream);
int i = 0;
@@ -830,7 +856,7 @@ void TestScanRegExp(const char* re_source, const char* expected) {
reinterpret_cast<const i::byte*>(re_source),
static_cast<unsigned>(strlen(re_source)));
i::HandleScope scope(CcTest::i_isolate());
- i::Scanner scanner(CcTest::i_isolate()->unicode_cache());
+ i::Scanner scanner(CcTest::i_isolate()->unicode_cache(), false);
scanner.Initialize(&stream);
i::Token::Value start = scanner.peek();
@@ -1550,7 +1576,7 @@ void TestParserSyncWithFlags(i::Handle<i::String> source,
// Preparse the data.
i::CompleteParserRecorder log;
if (test_preparser) {
- i::Scanner scanner(isolate->unicode_cache());
+ i::Scanner scanner(isolate->unicode_cache(), false);
i::GenericStringUtf16CharacterStream stream(source, 0, source->length());
i::Zone zone;
i::AstValueFactory ast_value_factory(
« 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