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 60d996cca2a1b0f7e8f4460a5484e002b2d01a04..0c282d495955d6c3abb02d2b1d060bb06f6e6883 100644 |
--- a/test/unittests/compiler/js-builtin-reducer-unittest.cc |
+++ b/test/unittests/compiler/js-builtin-reducer-unittest.cc |
@@ -264,6 +264,45 @@ TEST_F(JSBuiltinReducerTest, MathClz32WithPlainPrimitive) { |
} |
// ----------------------------------------------------------------------------- |
+// Math.cos |
+ |
+TEST_F(JSBuiltinReducerTest, MathCosWithNumber) { |
+ Node* function = MathFunction("cos"); |
+ |
+ 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, |
+ effect, control); |
+ Reduction r = Reduce(call); |
+ |
+ ASSERT_TRUE(r.Changed()); |
+ EXPECT_THAT(r.replacement(), IsNumberCos(p0)); |
+ } |
+} |
+ |
+TEST_F(JSBuiltinReducerTest, MathCosWithPlainPrimitive) { |
+ Node* function = MathFunction("cos"); |
+ |
+ Node* effect = graph()->start(); |
+ Node* control = graph()->start(); |
+ Node* context = UndefinedConstant(); |
+ Node* frame_state = graph()->start(); |
+ Node* p0 = Parameter(Type::PlainPrimitive(), 0); |
+ Node* call = graph()->NewNode(javascript()->CallFunction(3), function, |
+ UndefinedConstant(), p0, context, frame_state, |
+ effect, control); |
+ Reduction r = Reduce(call); |
+ |
+ ASSERT_TRUE(r.Changed()); |
+ EXPECT_THAT(r.replacement(), IsNumberCos(IsPlainPrimitiveToNumber(p0))); |
+} |
+ |
+// ----------------------------------------------------------------------------- |
// Math.exp |
TEST_F(JSBuiltinReducerTest, MathExpWithNumber) { |