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

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

Issue 121173009: String:WriteUtf8: Add REPLACE_INVALID_UTF8 option (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: DISALLOW_INVALID_UTF8 flag and fixes Created 6 years, 11 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
« src/unicode-inl.h ('K') | « 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 560 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 static const int kAllUtf8CharsSize = 571 static const int kAllUtf8CharsSize =
572 (unibrow::Utf8::kMaxOneByteChar + 1) + 572 (unibrow::Utf8::kMaxOneByteChar + 1) +
573 (unibrow::Utf8::kMaxTwoByteChar - unibrow::Utf8::kMaxOneByteChar) * 2 + 573 (unibrow::Utf8::kMaxTwoByteChar - unibrow::Utf8::kMaxOneByteChar) * 2 +
574 (unibrow::Utf8::kMaxThreeByteChar - unibrow::Utf8::kMaxTwoByteChar) * 3; 574 (unibrow::Utf8::kMaxThreeByteChar - unibrow::Utf8::kMaxTwoByteChar) * 3;
575 static const unsigned kAllUtf8CharsSizeU = 575 static const unsigned kAllUtf8CharsSizeU =
576 static_cast<unsigned>(kAllUtf8CharsSize); 576 static_cast<unsigned>(kAllUtf8CharsSize);
577 577
578 char buffer[kAllUtf8CharsSizeU]; 578 char buffer[kAllUtf8CharsSizeU];
579 unsigned cursor = 0; 579 unsigned cursor = 0;
580 for (int i = 0; i <= kMaxUC16Char; i++) { 580 for (int i = 0; i <= kMaxUC16Char; i++) {
581 // @TODO Fix this Utf8::Encode call site somehow.
581 cursor += unibrow::Utf8::Encode(buffer + cursor, 582 cursor += unibrow::Utf8::Encode(buffer + cursor,
582 i, 583 i,
583 unibrow::Utf16::kNoPreviousCharacter); 584 unibrow::Utf16::kNoPreviousCharacter);
584 } 585 }
585 ASSERT(cursor == kAllUtf8CharsSizeU); 586 ASSERT(cursor == kAllUtf8CharsSizeU);
586 587
587 i::Utf8ToUtf16CharacterStream stream(reinterpret_cast<const i::byte*>(buffer), 588 i::Utf8ToUtf16CharacterStream stream(reinterpret_cast<const i::byte*>(buffer),
588 kAllUtf8CharsSizeU); 589 kAllUtf8CharsSizeU);
589 for (int i = 0; i <= kMaxUC16Char; i++) { 590 for (int i = 0; i <= kMaxUC16Char; i++) {
590 CHECK_EQU(i, stream.pos()); 591 CHECK_EQU(i, stream.pos());
(...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after
1329 " b = function() { \n" 1330 " b = function() { \n"
1330 " 01; \n" 1331 " 01; \n"
1331 " }; \n" 1332 " }; \n"
1332 "}; \n"; 1333 "}; \n";
1333 v8::Script::Compile(v8::String::NewFromUtf8(CcTest::isolate(), script)); 1334 v8::Script::Compile(v8::String::NewFromUtf8(CcTest::isolate(), script));
1334 CHECK(try_catch.HasCaught()); 1335 CHECK(try_catch.HasCaught());
1335 v8::String::Utf8Value exception(try_catch.Exception()); 1336 v8::String::Utf8Value exception(try_catch.Exception());
1336 CHECK_EQ("SyntaxError: Octal literals are not allowed in strict mode.", 1337 CHECK_EQ("SyntaxError: Octal literals are not allowed in strict mode.",
1337 *exception); 1338 *exception);
1338 } 1339 }
OLDNEW
« src/unicode-inl.h ('K') | « test/cctest/test-api.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698