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

Unified Diff: test/cctest/test-code-stub-assembler.cc

Issue 2435953002: Add CodeStubAssembler::FlattenString (Closed)
Patch Set: deferred block Created 4 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/code-stub-assembler.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-code-stub-assembler.cc
diff --git a/test/cctest/test-code-stub-assembler.cc b/test/cctest/test-code-stub-assembler.cc
index c83af5860543fd9ab277390329688966260e2040..d55c82e8eac28bcdb761c714f59db24f9823b5d1 100644
--- a/test/cctest/test-code-stub-assembler.cc
+++ b/test/cctest/test-code-stub-assembler.cc
@@ -175,6 +175,46 @@ TEST(ToString) {
}
}
+TEST(FlattenString) {
+ Isolate* isolate(CcTest::InitIsolateOnce());
+ const int kNumParams = 1;
+ CodeStubAssemblerTester m(isolate, kNumParams);
+ m.Return(m.FlattenString(m.Parameter(0)));
+
+ Handle<Code> code = m.GenerateCode();
+ FunctionTester ft(code, kNumParams);
+
+ Handle<FixedArray> test_cases(isolate->factory()->NewFixedArray(4));
+ Handle<String> expected(
+ isolate->factory()->InternalizeUtf8String("hello, world!"));
+ test_cases->set(0, *expected);
+
+ Handle<String> string(
+ isolate->factory()->InternalizeUtf8String("filler hello, world! filler"));
+ Handle<String> sub_string(
+ isolate->factory()->NewProperSubString(string, 7, 20));
+ test_cases->set(1, *sub_string);
+
+ Handle<String> hello(isolate->factory()->InternalizeUtf8String("hello,"));
+ Handle<String> world(isolate->factory()->InternalizeUtf8String(" world!"));
+ Handle<String> cons_str(
+ isolate->factory()->NewConsString(hello, world).ToHandleChecked());
+ test_cases->set(2, *cons_str);
+
+ Handle<String> empty(isolate->factory()->InternalizeUtf8String(""));
+ Handle<String> fake_cons_str(
+ isolate->factory()->NewConsString(expected, empty).ToHandleChecked());
+ test_cases->set(3, *fake_cons_str);
+
+ for (int i = 0; i < 4; ++i) {
+ Handle<String> test = handle(String::cast(test_cases->get(i)));
+ Handle<Object> result = ft.Call(test).ToHandleChecked();
+ CHECK(result->IsString());
+ CHECK(Handle<String>::cast(result)->IsFlat());
+ CHECK(String::Equals(Handle<String>::cast(result), expected));
+ }
+}
+
TEST(TryToName) {
typedef CodeStubAssembler::Label Label;
typedef CodeStubAssembler::Variable Variable;
« no previous file with comments | « src/code-stub-assembler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698