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

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

Issue 11962035: Fix some latin-1 webkit units tests (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fixed last latin-1 webkit test failure Created 7 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 | Annotate | Revision Log
« no previous file with comments | « src/unicode-inl.h ('k') | test/mjsunit/regress/regress-latin-1.js » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 2
3 // Check that we can traverse very deep stacks of ConsStrings using 3 // Check that we can traverse very deep stacks of ConsStrings using
4 // StringCharacterStram. Check that Get(int) works on very deep stacks 4 // StringCharacterStram. Check that Get(int) works on very deep stacks
5 // of ConsStrings. These operations may not be very fast, but they 5 // of ConsStrings. These operations may not be very fast, but they
6 // should be possible without getting errors due to too deep recursion. 6 // should be possible without getting errors due to too deep recursion.
7 7
8 #include <stdlib.h> 8 #include <stdlib.h>
9 9
10 #include "v8.h" 10 #include "v8.h"
(...skipping 1259 matching lines...) Expand 10 before | Expand all | Expand 10 after
1270 CHECK(expected->Equals(result)); 1270 CHECK(expected->Equals(result));
1271 } 1271 }
1272 1272
1273 1273
1274 TEST(IsAscii) { 1274 TEST(IsAscii) {
1275 CHECK(String::IsAscii(static_cast<char*>(NULL), 0)); 1275 CHECK(String::IsAscii(static_cast<char*>(NULL), 0));
1276 CHECK(String::IsOneByte(static_cast<uc16*>(NULL), 0)); 1276 CHECK(String::IsOneByte(static_cast<uc16*>(NULL), 0));
1277 } 1277 }
1278 1278
1279 1279
1280 static bool CanBeConvertedToLatin1(uint16_t c) { 1280 template<typename Op, bool return_first>
1281 CHECK(c > unibrow::Latin1::kMaxChar); 1281 static uint16_t ConvertLatin1(uint16_t c) {
1282 uint32_t result[4]; 1282 uint32_t result[Op::kMaxWidth];
1283 int chars; 1283 int chars;
1284 chars = unibrow::ToLowercase::Convert(c, 0, result, NULL); 1284 chars = Op::Convert(c, 0, result, NULL);
1285 if (chars > 0) { 1285 if (chars == 0) return 0;
1286 CHECK_LE(chars, static_cast<int>(sizeof(result))); 1286 CHECK_LE(chars, static_cast<int>(sizeof(result)));
1287 for (int i = 0; i < chars; i++) { 1287 if (!return_first && chars > 1) {
1288 if (result[i] <= unibrow::Latin1::kMaxChar) { 1288 return 0;
1289 return true;
1290 }
1291 }
1292 } 1289 }
1293 chars = unibrow::ToUppercase::Convert(c, 0, result, NULL); 1290 return result[0];
1294 if (chars > 0) { 1291 }
1295 CHECK_LE(chars, static_cast<int>(sizeof(result))); 1292
1296 for (int i = 0; i < chars; i++) { 1293
1297 if (result[i] <= unibrow::Latin1::kMaxChar) { 1294 static void CheckCanonicalEquivalence(uint16_t c, uint16_t test) {
1298 return true; 1295 uint16_t expect = ConvertLatin1<unibrow::Ecma262UnCanonicalize, true>(c);
1299 } 1296 if (expect > unibrow::Latin1::kMaxChar) expect = 0;
1300 } 1297 CHECK_EQ(expect, test);
1301 }
1302 return false;
1303 } 1298 }
1304 1299
1305 1300
1306 TEST(Latin1) { 1301 TEST(Latin1) {
1307 #ifndef ENABLE_LATIN_1 1302 #ifndef ENABLE_LATIN_1
1308 if (true) return; 1303 if (true) return;
1309 #endif 1304 #endif
1310 for (uint16_t c = unibrow::Latin1::kMaxChar + 1; c != 0; c++) { 1305 using namespace unibrow;
1311 CHECK_EQ(CanBeConvertedToLatin1(c), 1306 for (uint16_t c = Latin1::kMaxChar + 1; c != 0; c++) {
1312 unibrow::Latin1::NonLatin1CanBeConvertedToLatin1(c)); 1307 uint16_t lower = ConvertLatin1<ToLowercase, false>(c);
1308 uint16_t upper = ConvertLatin1<ToUppercase, false>(c);
1309 uint16_t test = Latin1::ConvertNonLatin1ToLatin1(c);
1310 // Filter out all character whose upper is not their lower or vice versa.
1311 if (lower == 0 && upper == 0) {
1312 CheckCanonicalEquivalence(c, test);
1313 continue;
1314 }
1315 if (lower > Latin1::kMaxChar && upper > Latin1::kMaxChar) {
1316 CheckCanonicalEquivalence(c, test);
1317 continue;
1318 }
1319 if (lower == 0 && upper != 0) {
1320 lower = ConvertLatin1<ToLowercase, false>(upper);
1321 }
1322 if (upper == 0 && lower != c) {
1323 upper = ConvertLatin1<ToUppercase, false>(lower);
1324 }
1325 if (lower > Latin1::kMaxChar && upper > Latin1::kMaxChar) {
1326 CheckCanonicalEquivalence(c, test);
1327 continue;
1328 }
1329 if (upper != c && lower != c) {
1330 CheckCanonicalEquivalence(c, test);
1331 continue;
1332 }
1333 CHECK_EQ(Min(upper, lower), test);
1313 } 1334 }
1314 } 1335 }
1336
OLDNEW
« no previous file with comments | « src/unicode-inl.h ('k') | test/mjsunit/regress/regress-latin-1.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698