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

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

Issue 2539093002: [runtime] Port simple String.prototype.indexOf cases to TF Builtin (Closed)
Patch Set: merging with master Created 4 years 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 | « test/cctest/cctest.h ('k') | test/mjsunit/string-indexof-1.js » ('j') | 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 80c8f92ac431ef8d0a714a3565db57a94d97dbd2..80cbd7a62e9b2d660b72ae1432d7133a4191ed08 100644
--- a/test/cctest/test-strings.cc
+++ b/test/cctest/test-strings.cc
@@ -1608,3 +1608,38 @@ TEST(Regress609831) {
CHECK(v8::Utils::OpenHandle(*result)->IsSeqTwoByteString());
}
}
+
+TEST(ExternalStringIndexOf) {
+ CcTest::InitializeVM();
+ LocalContext context;
+ v8::HandleScope scope(CcTest::isolate());
+
+ const char* raw_string = "abcdefghijklmnopqrstuvwxyz";
+ v8::Local<v8::String> string =
+ v8::String::NewExternalOneByte(CcTest::isolate(),
+ new StaticOneByteResource(raw_string))
+ .ToLocalChecked();
+ v8::Local<v8::Object> global = context->Global();
+ global->Set(context.local(), v8_str("external"), string).FromJust();
+
+ char source[] = "external.indexOf('%')";
+ for (size_t i = 0; i < strlen(raw_string); i++) {
+ source[18] = raw_string[i];
+ int result_position = static_cast<int>(i);
+ CHECK_EQ(result_position,
+ CompileRun(source)->Int32Value(context.local()).FromJust());
+ }
+ CHECK_EQ(-1,
+ CompileRun("external.indexOf('abcdefghijklmnopqrstuvwxyz%%%%%%')")
+ ->Int32Value(context.local())
+ .FromJust());
+ CHECK_EQ(1, CompileRun("external.indexOf('', 1)")
+ ->Int32Value(context.local())
+ .FromJust());
+ CHECK_EQ(-1, CompileRun("external.indexOf('a', 1)")
+ ->Int32Value(context.local())
+ .FromJust());
+ CHECK_EQ(-1, CompileRun("external.indexOf('$')")
+ ->Int32Value(context.local())
+ .FromJust());
+}
« no previous file with comments | « test/cctest/cctest.h ('k') | test/mjsunit/string-indexof-1.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698