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

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

Issue 628223002: Reland: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/i18n.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-strings.cc
diff --git a/test/cctest/test-strings.cc b/test/cctest/test-strings.cc
index ef13c4dadf682f6e178dce71c9e70009d703a7e9..c0b2cbf3caf934f920da34df7f98a5cbf48c5023 100644
--- a/test/cctest/test-strings.cc
+++ b/test/cctest/test-strings.cc
@@ -1292,6 +1292,42 @@ TEST(RobustSubStringStub) {
}
+namespace {
+
+int* global_use_counts = NULL;
+
+void MockUseCounterCallback(v8::Isolate* isolate,
+ v8::Isolate::UseCounterFeature feature) {
+ ++global_use_counts[feature];
+}
+}
+
+
+TEST(CountBreakIterator) {
+ CcTest::InitializeVM();
+ v8::HandleScope scope(CcTest::isolate());
+ LocalContext context;
+ int use_counts[v8::Isolate::kUseCounterFeatureCount] = {};
+ global_use_counts = use_counts;
+ CcTest::isolate()->SetUseCounterCallback(MockUseCounterCallback);
+ CHECK_EQ(0, use_counts[v8::Isolate::kBreakIterator]);
+ v8::Local<v8::Value> result = CompileRun(
+ "(function() {"
+ " if (!this.Intl) return 0;"
+ " var iterator = Intl.v8BreakIterator(['en']);"
+ " iterator.adoptText('Now is the time');"
+ " iterator.next();"
+ " return iterator.next();"
+ "})();");
+ CHECK(result->IsNumber());
+ int uses = result->ToInt32()->Value() == 0 ? 0 : 1;
+ CHECK_EQ(uses, use_counts[v8::Isolate::kBreakIterator]);
+ // Make sure GC cleans up the break iterator, so we don't get a memory leak
+ // reported by ASAN.
+ CcTest::isolate()->LowMemoryNotification();
+}
+
+
TEST(StringReplaceAtomTwoByteResult) {
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
« 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