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

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

Issue 2759513002: Remove Factory::NewStringFromASCII method. (Closed)
Patch Set: Created 3 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/wasm/wasm-objects.cc ('k') | test/cctest/test-strings.cc » ('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 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/factory.h" // for i::Factory::NewExternalStringFrom*Byte 5 #include "src/factory.h" // for i::Factory::NewExternalStringFrom*Byte
6 #include "src/feedback-vector-inl.h" // for include "src/factory.h" 6 #include "src/feedback-vector-inl.h" // for include "src/factory.h"
7 #include "src/objects-inl.h" 7 #include "src/objects-inl.h"
8 #include "src/parsing/scanner-character-streams.h" 8 #include "src/parsing/scanner-character-streams.h"
9 #include "src/parsing/scanner.h" 9 #include "src/parsing/scanner.h"
10 #include "test/cctest/cctest.h" 10 #include "test/cctest/cctest.h"
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 } 304 }
305 TestExternalResource resource(uc16_buffer.get(), length); 305 TestExternalResource resource(uc16_buffer.get(), length);
306 i::Handle<i::String> uc16_string( 306 i::Handle<i::String> uc16_string(
307 factory->NewExternalStringFromTwoByte(&resource).ToHandleChecked()); 307 factory->NewExternalStringFromTwoByte(&resource).ToHandleChecked());
308 std::unique_ptr<i::Utf16CharacterStream> uc16_stream( 308 std::unique_ptr<i::Utf16CharacterStream> uc16_stream(
309 i::ScannerStream::For(uc16_string, start, end)); 309 i::ScannerStream::For(uc16_string, start, end));
310 TestCharacterStream(one_byte_source, uc16_stream.get(), length, start, end); 310 TestCharacterStream(one_byte_source, uc16_stream.get(), length, start, end);
311 } 311 }
312 312
313 // 1-byte external string 313 // 1-byte external string
314 i::Vector<const char> one_byte_vector(one_byte_source, 314 i::Vector<const uint8_t> one_byte_vector =
315 static_cast<int>(length)); 315 i::OneByteVector(one_byte_source, static_cast<int>(length));
316 i::Handle<i::String> one_byte_string = 316 i::Handle<i::String> one_byte_string =
317 factory->NewStringFromAscii(one_byte_vector).ToHandleChecked(); 317 factory->NewStringFromOneByte(one_byte_vector).ToHandleChecked();
318 { 318 {
319 TestExternalOneByteResource one_byte_resource(one_byte_source, length); 319 TestExternalOneByteResource one_byte_resource(one_byte_source, length);
320 i::Handle<i::String> ext_one_byte_string( 320 i::Handle<i::String> ext_one_byte_string(
321 factory->NewExternalStringFromOneByte(&one_byte_resource) 321 factory->NewExternalStringFromOneByte(&one_byte_resource)
322 .ToHandleChecked()); 322 .ToHandleChecked());
323 std::unique_ptr<i::Utf16CharacterStream> one_byte_stream( 323 std::unique_ptr<i::Utf16CharacterStream> one_byte_stream(
324 i::ScannerStream::For(ext_one_byte_string, start, end)); 324 i::ScannerStream::For(ext_one_byte_string, start, end));
325 TestCharacterStream(one_byte_source, one_byte_stream.get(), length, start, 325 TestCharacterStream(one_byte_source, one_byte_stream.get(), length, start,
326 end); 326 end);
327 } 327 }
(...skipping 15 matching lines...) Expand all
343 TestCharacterStream(one_byte_source, two_byte_string_stream.get(), length, 343 TestCharacterStream(one_byte_source, two_byte_string_stream.get(), length,
344 start, end); 344 start, end);
345 } 345 }
346 346
347 // Streaming has no notion of start/end, so let's skip streaming tests for 347 // Streaming has no notion of start/end, so let's skip streaming tests for
348 // these cases. 348 // these cases.
349 if (start != 0 || end != length) return; 349 if (start != 0 || end != length) return;
350 350
351 // 1-byte streaming stream, single + many chunks. 351 // 1-byte streaming stream, single + many chunks.
352 { 352 {
353 const uint8_t* data = 353 const uint8_t* data = one_byte_vector.begin();
354 reinterpret_cast<const uint8_t*>(one_byte_vector.begin()); 354 const uint8_t* data_end = one_byte_vector.end();
355 const uint8_t* data_end =
356 reinterpret_cast<const uint8_t*>(one_byte_vector.end());
357 355
358 ChunkSource single_chunk(data, data_end - data, false); 356 ChunkSource single_chunk(data, data_end - data, false);
359 std::unique_ptr<i::Utf16CharacterStream> one_byte_streaming_stream( 357 std::unique_ptr<i::Utf16CharacterStream> one_byte_streaming_stream(
360 i::ScannerStream::For(&single_chunk, 358 i::ScannerStream::For(&single_chunk,
361 v8::ScriptCompiler::StreamedSource::ONE_BYTE, 359 v8::ScriptCompiler::StreamedSource::ONE_BYTE,
362 nullptr)); 360 nullptr));
363 TestCharacterStream(one_byte_source, one_byte_streaming_stream.get(), 361 TestCharacterStream(one_byte_source, one_byte_streaming_stream.get(),
364 length, start, end); 362 length, start, end);
365 363
366 ChunkSource many_chunks(data, data_end - data, true); 364 ChunkSource many_chunks(data, data_end - data, true);
367 one_byte_streaming_stream.reset(i::ScannerStream::For( 365 one_byte_streaming_stream.reset(i::ScannerStream::For(
368 &many_chunks, v8::ScriptCompiler::StreamedSource::ONE_BYTE, nullptr)); 366 &many_chunks, v8::ScriptCompiler::StreamedSource::ONE_BYTE, nullptr));
369 TestCharacterStream(one_byte_source, one_byte_streaming_stream.get(), 367 TestCharacterStream(one_byte_source, one_byte_streaming_stream.get(),
370 length, start, end); 368 length, start, end);
371 } 369 }
372 370
373 // UTF-8 streaming stream, single + many chunks. 371 // UTF-8 streaming stream, single + many chunks.
374 { 372 {
375 const uint8_t* data = 373 const uint8_t* data = one_byte_vector.begin();
376 reinterpret_cast<const uint8_t*>(one_byte_vector.begin()); 374 const uint8_t* data_end = one_byte_vector.end();
377 const uint8_t* data_end =
378 reinterpret_cast<const uint8_t*>(one_byte_vector.end());
379 ChunkSource chunks(data, data_end - data, false); 375 ChunkSource chunks(data, data_end - data, false);
380 std::unique_ptr<i::Utf16CharacterStream> utf8_streaming_stream( 376 std::unique_ptr<i::Utf16CharacterStream> utf8_streaming_stream(
381 i::ScannerStream::For(&chunks, v8::ScriptCompiler::StreamedSource::UTF8, 377 i::ScannerStream::For(&chunks, v8::ScriptCompiler::StreamedSource::UTF8,
382 nullptr)); 378 nullptr));
383 TestCharacterStream(one_byte_source, utf8_streaming_stream.get(), length, 379 TestCharacterStream(one_byte_source, utf8_streaming_stream.get(), length,
384 start, end); 380 start, end);
385 381
386 ChunkSource many_chunks(data, data_end - data, true); 382 ChunkSource many_chunks(data, data_end - data, true);
387 utf8_streaming_stream.reset(i::ScannerStream::For( 383 utf8_streaming_stream.reset(i::ScannerStream::For(
388 &many_chunks, v8::ScriptCompiler::StreamedSource::UTF8, nullptr)); 384 &many_chunks, v8::ScriptCompiler::StreamedSource::UTF8, nullptr));
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 // 65533) instead of the incorrectly coded Latin1 char. 443 // 65533) instead of the incorrectly coded Latin1 char.
448 ChunkSource chunks(bytes, len, false); 444 ChunkSource chunks(bytes, len, false);
449 std::unique_ptr<i::Utf16CharacterStream> stream(i::ScannerStream::For( 445 std::unique_ptr<i::Utf16CharacterStream> stream(i::ScannerStream::For(
450 &chunks, v8::ScriptCompiler::StreamedSource::UTF8, nullptr)); 446 &chunks, v8::ScriptCompiler::StreamedSource::UTF8, nullptr));
451 for (size_t i = 0; i < len; i++) { 447 for (size_t i = 0; i < len; i++) {
452 CHECK_EQ(unicode[i], stream->Advance()); 448 CHECK_EQ(unicode[i], stream->Advance());
453 } 449 }
454 CHECK_EQ(i::Utf16CharacterStream::kEndOfInput, stream->Advance()); 450 CHECK_EQ(i::Utf16CharacterStream::kEndOfInput, stream->Advance());
455 } 451 }
456 } 452 }
OLDNEW
« no previous file with comments | « src/wasm/wasm-objects.cc ('k') | test/cctest/test-strings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698