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 a8441afc5d0c1a54e676d5e97a8610a5aeebbfb7..9a1378a53915eef55daa1798d1a4ea2a9d7b4d17 100644 |
--- a/test/unittests/compiler/js-builtin-reducer-unittest.cc |
+++ b/test/unittests/compiler/js-builtin-reducer-unittest.cc |
@@ -87,6 +87,45 @@ Type* const kNumberTypes[] = { |
// ----------------------------------------------------------------------------- |
+// Math.abs |
+ |
+TEST_F(JSBuiltinReducerTest, MathAbsWithNumber) { |
+ Node* function = MathFunction("abs"); |
+ |
+ 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(), IsNumberAbs(p0)); |
+ } |
+} |
+ |
+TEST_F(JSBuiltinReducerTest, MathAbsWithPlainPrimitive) { |
+ Node* function = MathFunction("abs"); |
+ |
+ 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(), IsNumberAbs(IsPlainPrimitiveToNumber(p0))); |
+} |
+ |
+// ----------------------------------------------------------------------------- |
// Math.atan |
TEST_F(JSBuiltinReducerTest, MathAtanWithNumber) { |