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

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

Issue 619913002: Add a use counter for Intl.v8BreakIterator (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 2 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/i18n.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 1274 matching lines...) Expand 10 before | Expand all | Expand 10 after
1285 string = v8::Utils::OpenHandle(v8::String::Cast(*result)); 1285 string = v8::Utils::OpenHandle(v8::String::Cast(*result));
1286 CHECK_EQ("cdefghijklmnopq", string->ToCString().get()); 1286 CHECK_EQ("cdefghijklmnopq", string->ToCString().get());
1287 1287
1288 // Test that out-of-bounds substring of a slice fails when the indices 1288 // Test that out-of-bounds substring of a slice fails when the indices
1289 // would have been valid for the underlying string. 1289 // would have been valid for the underlying string.
1290 CompileRun("var slice = long.slice(1, 15);"); 1290 CompileRun("var slice = long.slice(1, 15);");
1291 CheckException("%_SubString(slice, 0, 17);"); 1291 CheckException("%_SubString(slice, 0, 17);");
1292 } 1292 }
1293 1293
1294 1294
1295 namespace {
1296
1297 int* global_use_counts = NULL;
1298
1299 void MockUseCounterCallback(v8::Isolate* isolate,
1300 v8::Isolate::UseCounterFeature feature) {
1301 ++global_use_counts[feature];
1302 }
1303 }
1304
1305
1306 TEST(CountBreakIterator) {
1307 CcTest::InitializeVM();
1308 v8::HandleScope scope(CcTest::isolate());
1309 LocalContext context;
1310 int use_counts[v8::Isolate::kUseCounterFeatureCount] = {};
1311 global_use_counts = use_counts;
1312 CcTest::isolate()->SetUseCounterCallback(MockUseCounterCallback);
1313 CHECK_EQ(0, use_counts[v8::Isolate::kBreakIterator]);
1314 v8::Local<v8::Value> result = CompileRun(
1315 "var iterator = Intl.v8BreakIterator(['en']);"
1316 "iterator.adoptText('Now is the time');"
1317 "iterator.next();"
1318 "iterator.next();");
1319 CHECK(result->IsNumber());
1320 CHECK_EQ(1, use_counts[v8::Isolate::kBreakIterator]);
1321 }
1322
1323
1295 TEST(StringReplaceAtomTwoByteResult) { 1324 TEST(StringReplaceAtomTwoByteResult) {
1296 CcTest::InitializeVM(); 1325 CcTest::InitializeVM();
1297 v8::HandleScope scope(CcTest::isolate()); 1326 v8::HandleScope scope(CcTest::isolate());
1298 LocalContext context; 1327 LocalContext context;
1299 v8::Local<v8::Value> result = CompileRun( 1328 v8::Local<v8::Value> result = CompileRun(
1300 "var subject = 'one_byte~only~string~'; " 1329 "var subject = 'one_byte~only~string~'; "
1301 "var replace = '\x80'; " 1330 "var replace = '\x80'; "
1302 "subject.replace(/~/g, replace); "); 1331 "subject.replace(/~/g, replace); ");
1303 CHECK(result->IsString()); 1332 CHECK(result->IsString());
1304 Handle<String> string = v8::Utils::OpenHandle(v8::String::Cast(*result)); 1333 Handle<String> string = v8::Utils::OpenHandle(v8::String::Cast(*result));
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1419 CHECK(isolate->has_pending_exception()); \ 1448 CHECK(isolate->has_pending_exception()); \
1420 isolate->clear_pending_exception(); \ 1449 isolate->clear_pending_exception(); \
1421 dummy.Dispose(); \ 1450 dummy.Dispose(); \
1422 } 1451 }
1423 1452
1424 INVALID_STRING_TEST(NewStringFromAscii, char) 1453 INVALID_STRING_TEST(NewStringFromAscii, char)
1425 INVALID_STRING_TEST(NewStringFromUtf8, char) 1454 INVALID_STRING_TEST(NewStringFromUtf8, char)
1426 INVALID_STRING_TEST(NewStringFromOneByte, uint8_t) 1455 INVALID_STRING_TEST(NewStringFromOneByte, uint8_t)
1427 1456
1428 #undef INVALID_STRING_TEST 1457 #undef INVALID_STRING_TEST
OLDNEW
« no previous file with comments | « src/i18n.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698