Index: test/unittests/compiler/js-builtin-reducer-unittest.cc |
diff --git a/test/unittests/compiler/js-builtin-reducer-unittest.cc b/test/unittests/compiler/js-builtin-reducer-unittest.cc |
index 0f8eed7958587baf4ff6445d1f2fc0caa9557261..c0af1d040f59baddab6414b68b0a9fb2fcffb5f6 100644 |
--- a/test/unittests/compiler/js-builtin-reducer-unittest.cc |
+++ b/test/unittests/compiler/js-builtin-reducer-unittest.cc |
@@ -49,6 +49,19 @@ class JSBuiltinReducerTest : public TypedGraphTest { |
return HeapConstant(f); |
} |
+ Node* StringFunction(const char* name) { |
+ Handle<Object> m = |
+ JSObject::GetProperty( |
+ isolate()->global_object(), |
+ isolate()->factory()->NewStringFromAsciiChecked("String")) |
+ .ToHandleChecked(); |
+ Handle<JSFunction> f = Handle<JSFunction>::cast( |
+ Object::GetProperty( |
+ m, isolate()->factory()->NewStringFromAsciiChecked(name)) |
+ .ToHandleChecked()); |
+ return HeapConstant(f); |
+ } |
+ |
JSOperatorBuilder* javascript() { return &javascript_; } |
private: |
@@ -189,6 +202,28 @@ TEST_F(JSBuiltinReducerTest, MathFround) { |
} |
} |
+// ----------------------------------------------------------------------------- |
+// String.fromCharCode |
+ |
+TEST_F(JSBuiltinReducerTest, StringFromCharCode) { |
+ Node* function = StringFunction("fromCharCode"); |
+ |
+ Node* effect = graph()->start(); |
+ Node* control = graph()->start(); |
+ Node* context = UndefinedConstant(); |
+ Node* frame_state = graph()->start(); |
+ TRACED_FOREACH(Type*, t0, kNumberTypes) { |
+ Node* p0 = Parameter(t0, 0); |
+ Node* call = graph()->NewNode(javascript()->CallFunction(3), function, |
+ UndefinedConstant(), p0, context, frame_state, |
+ frame_state, effect, control); |
+ Reduction r = Reduce(call); |
+ |
+ ASSERT_TRUE(r.Changed()); |
+ EXPECT_THAT(r.replacement(), IsStringFromCharCode(p0)); |
+ } |
+} |
+ |
} // namespace compiler |
} // namespace internal |
} // namespace v8 |