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

Unified Diff: test/cctest/test-parsing.cc

Issue 2256273002: Remove unused Utf8ToUtf16CharacterStream. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 4 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 | « src/parsing/scanner-character-streams.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 12c6a4012d2e1d5a8422e464af1c56af519e3dea..deaecba82148bd583c22f78f378a400a29eb95db 100644
--- a/test/cctest/test-parsing.cc
+++ b/test/cctest/test-parsing.cc
@@ -64,14 +64,13 @@ TEST(ScanKeywords) {
KeywordToken key_token;
i::UnicodeCache unicode_cache;
- i::byte buffer[32];
+ char buffer[32];
for (int i = 0; (key_token = keywords[i]).keyword != NULL; i++) {
- const i::byte* keyword =
- reinterpret_cast<const i::byte*>(key_token.keyword);
- int length = i::StrLength(key_token.keyword);
+ const char* keyword = key_token.keyword;
+ size_t length = strlen(key_token.keyword);
CHECK(static_cast<int>(sizeof(buffer)) >= length);
{
- i::Utf8ToUtf16CharacterStream stream(keyword, length);
+ i::ExternalOneByteStringUtf16CharacterStream stream(keyword, length);
i::Scanner scanner(&unicode_cache);
scanner.Initialize(&stream);
CHECK_EQ(key_token.token, scanner.Next());
@@ -79,7 +78,7 @@ TEST(ScanKeywords) {
}
// Removing characters will make keyword matching fail.
{
- i::Utf8ToUtf16CharacterStream stream(keyword, length - 1);
+ i::ExternalOneByteStringUtf16CharacterStream stream(keyword, length - 1);
i::Scanner scanner(&unicode_cache);
scanner.Initialize(&stream);
CHECK_EQ(i::Token::IDENTIFIER, scanner.Next());
@@ -90,7 +89,7 @@ TEST(ScanKeywords) {
for (int j = 0; j < static_cast<int>(arraysize(chars_to_append)); ++j) {
i::MemMove(buffer, keyword, length);
buffer[length] = chars_to_append[j];
- i::Utf8ToUtf16CharacterStream stream(buffer, length + 1);
+ i::ExternalOneByteStringUtf16CharacterStream stream(buffer, length + 1);
i::Scanner scanner(&unicode_cache);
scanner.Initialize(&stream);
CHECK_EQ(i::Token::IDENTIFIER, scanner.Next());
@@ -100,7 +99,7 @@ TEST(ScanKeywords) {
{
i::MemMove(buffer, keyword, length);
buffer[length - 1] = '_';
- i::Utf8ToUtf16CharacterStream stream(buffer, length);
+ i::ExternalOneByteStringUtf16CharacterStream stream(buffer, length);
i::Scanner scanner(&unicode_cache);
scanner.Initialize(&stream);
CHECK_EQ(i::Token::IDENTIFIER, scanner.Next());
@@ -165,9 +164,8 @@ TEST(ScanHTMLEndComments) {
i::GetCurrentStackPosition() - 128 * 1024);
uintptr_t stack_limit = CcTest::i_isolate()->stack_guard()->real_climit();
for (int i = 0; tests[i]; i++) {
- const i::byte* source =
- reinterpret_cast<const i::byte*>(tests[i]);
- i::Utf8ToUtf16CharacterStream stream(source, i::StrLength(tests[i]));
+ const char* source = tests[i];
+ i::ExternalOneByteStringUtf16CharacterStream stream(source);
i::CompleteParserRecorder log;
i::Scanner scanner(CcTest::i_isolate()->unicode_cache());
scanner.Initialize(&stream);
@@ -183,9 +181,8 @@ TEST(ScanHTMLEndComments) {
}
for (int i = 0; fail_tests[i]; i++) {
- const i::byte* source =
- reinterpret_cast<const i::byte*>(fail_tests[i]);
- i::Utf8ToUtf16CharacterStream stream(source, i::StrLength(fail_tests[i]));
+ const char* source = fail_tests[i];
+ i::ExternalOneByteStringUtf16CharacterStream stream(source);
i::CompleteParserRecorder log;
i::Scanner scanner(CcTest::i_isolate()->unicode_cache());
scanner.Initialize(&stream);
@@ -343,9 +340,7 @@ TEST(StandAlonePreParser) {
uintptr_t stack_limit = CcTest::i_isolate()->stack_guard()->real_climit();
for (int i = 0; programs[i]; i++) {
const char* program = programs[i];
- i::Utf8ToUtf16CharacterStream stream(
- reinterpret_cast<const i::byte*>(program),
- static_cast<unsigned>(strlen(program)));
+ i::ExternalOneByteStringUtf16CharacterStream stream(program);
i::CompleteParserRecorder log;
i::Scanner scanner(CcTest::i_isolate()->unicode_cache());
scanner.Initialize(&stream);
@@ -379,9 +374,7 @@ TEST(StandAlonePreParserNoNatives) {
uintptr_t stack_limit = CcTest::i_isolate()->stack_guard()->real_climit();
for (int i = 0; programs[i]; i++) {
const char* program = programs[i];
- i::Utf8ToUtf16CharacterStream stream(
- reinterpret_cast<const i::byte*>(program),
- static_cast<unsigned>(strlen(program)));
+ i::ExternalOneByteStringUtf16CharacterStream stream(program);
i::CompleteParserRecorder log;
i::Scanner scanner(CcTest::i_isolate()->unicode_cache());
scanner.Initialize(&stream);
@@ -450,9 +443,7 @@ TEST(RegressChromium62639) {
// and then used the invalid currently scanned literal. This always
// failed in debug mode, and sometimes crashed in release mode.
- i::Utf8ToUtf16CharacterStream stream(
- reinterpret_cast<const i::byte*>(program),
- static_cast<unsigned>(strlen(program)));
+ i::ExternalOneByteStringUtf16CharacterStream stream(program);
i::CompleteParserRecorder log;
i::Scanner scanner(CcTest::i_isolate()->unicode_cache());
scanner.Initialize(&stream);
@@ -536,9 +527,8 @@ TEST(PreParseOverflow) {
uintptr_t stack_limit = CcTest::i_isolate()->stack_guard()->real_climit();
- i::Utf8ToUtf16CharacterStream stream(
- reinterpret_cast<const i::byte*>(program.get()),
- static_cast<unsigned>(kProgramSize));
+ i::ExternalOneByteStringUtf16CharacterStream stream(program.get(),
+ kProgramSize);
i::CompleteParserRecorder log;
i::Scanner scanner(CcTest::i_isolate()->unicode_cache());
scanner.Initialize(&stream);
@@ -606,8 +596,8 @@ void TestCharacterStream(const char* one_byte_source, unsigned length,
end);
i::GenericStringUtf16CharacterStream string_stream(one_byte_string, start,
end);
- i::Utf8ToUtf16CharacterStream utf8_stream(
- reinterpret_cast<const i::byte*>(one_byte_source), end);
+ i::ExternalOneByteStringUtf16CharacterStream utf8_stream(one_byte_source,
+ end);
utf8_stream.SeekForward(start);
unsigned i = start;
@@ -714,6 +704,7 @@ void TestCharacterStream(const char* one_byte_source, unsigned length,
CHECK_LT(c4, 0);
}
+#undef CHECK_EQU
TEST(CharacterStreams) {
v8::Isolate* isolate = CcTest::isolate();
@@ -736,63 +727,6 @@ TEST(CharacterStreams) {
}
-TEST(Utf8CharacterStream) {
- static const unsigned kMaxUC16CharU = unibrow::Utf8::kMaxThreeByteChar;
- static const int kMaxUC16Char = static_cast<int>(kMaxUC16CharU);
-
- static const int kAllUtf8CharsSize =
- (unibrow::Utf8::kMaxOneByteChar + 1) +
- (unibrow::Utf8::kMaxTwoByteChar - unibrow::Utf8::kMaxOneByteChar) * 2 +
- (unibrow::Utf8::kMaxThreeByteChar - unibrow::Utf8::kMaxTwoByteChar) * 3;
- static const unsigned kAllUtf8CharsSizeU =
- static_cast<unsigned>(kAllUtf8CharsSize);
-
- char buffer[kAllUtf8CharsSizeU];
- unsigned cursor = 0;
- for (int i = 0; i <= kMaxUC16Char; i++) {
- cursor += unibrow::Utf8::Encode(buffer + cursor, i,
- unibrow::Utf16::kNoPreviousCharacter, true);
- }
- CHECK(cursor == kAllUtf8CharsSizeU);
-
- i::Utf8ToUtf16CharacterStream stream(reinterpret_cast<const i::byte*>(buffer),
- kAllUtf8CharsSizeU);
- int32_t bad = unibrow::Utf8::kBadChar;
- for (int i = 0; i <= kMaxUC16Char; i++) {
- CHECK_EQU(i, stream.pos());
- int32_t c = stream.Advance();
- if (i >= 0xd800 && i <= 0xdfff) {
- CHECK_EQ(bad, c);
- } else {
- CHECK_EQ(i, c);
- }
- CHECK_EQU(i + 1, stream.pos());
- }
- for (int i = kMaxUC16Char; i >= 0; i--) {
- CHECK_EQU(i + 1, stream.pos());
- stream.PushBack(i);
- CHECK_EQU(i, stream.pos());
- }
- int i = 0;
- while (stream.pos() < kMaxUC16CharU) {
- CHECK_EQU(i, stream.pos());
- int progress = static_cast<int>(stream.SeekForward(12));
- i += progress;
- int32_t c = stream.Advance();
- if (i >= 0xd800 && i <= 0xdfff) {
- CHECK_EQ(bad, c);
- } else if (i <= kMaxUC16Char) {
- CHECK_EQ(i, c);
- } else {
- CHECK_EQ(-1, c);
- }
- i += 1;
- CHECK_EQU(i, stream.pos());
- }
-}
-
-#undef CHECK_EQU
-
void TestStreamScanner(i::Utf16CharacterStream* stream,
i::Token::Value* expected_tokens,
int skip_pos = 0, // Zero means not skipping.
@@ -817,8 +751,7 @@ TEST(StreamScanner) {
v8::V8::Initialize();
const char* str1 = "{ foo get for : */ <- \n\n /*foo*/ bib";
- i::Utf8ToUtf16CharacterStream stream1(reinterpret_cast<const i::byte*>(str1),
- static_cast<unsigned>(strlen(str1)));
+ i::ExternalOneByteStringUtf16CharacterStream stream1(str1);
i::Token::Value expectations1[] = {
i::Token::LBRACE,
i::Token::IDENTIFIER,
@@ -836,8 +769,7 @@ TEST(StreamScanner) {
TestStreamScanner(&stream1, expectations1, 0, 0);
const char* str2 = "case default const {THIS\nPART\nSKIPPED} do";
- i::Utf8ToUtf16CharacterStream stream2(reinterpret_cast<const i::byte*>(str2),
- static_cast<unsigned>(strlen(str2)));
+ i::ExternalOneByteStringUtf16CharacterStream stream2(str2);
i::Token::Value expectations2[] = {
i::Token::CASE,
i::Token::DEFAULT,
@@ -867,18 +799,14 @@ TEST(StreamScanner) {
for (int i = 0; i <= 4; i++) {
expectations3[6 - i] = i::Token::ILLEGAL;
expectations3[5 - i] = i::Token::EOS;
- i::Utf8ToUtf16CharacterStream stream3(
- reinterpret_cast<const i::byte*>(str3),
- static_cast<unsigned>(strlen(str3)));
+ i::ExternalOneByteStringUtf16CharacterStream stream3(str3);
TestStreamScanner(&stream3, expectations3, 1, 1 + i);
}
}
void TestScanRegExp(const char* re_source, const char* expected) {
- i::Utf8ToUtf16CharacterStream stream(
- reinterpret_cast<const i::byte*>(re_source),
- static_cast<unsigned>(strlen(re_source)));
+ i::ExternalOneByteStringUtf16CharacterStream stream(re_source);
i::HandleScope scope(CcTest::i_isolate());
i::Scanner scanner(CcTest::i_isolate()->unicode_cache());
scanner.Initialize(&stream);
« no previous file with comments | « src/parsing/scanner-character-streams.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698