Index: test/unittests/compiler/js-typed-lowering-unittest.cc |
diff --git a/test/unittests/compiler/js-typed-lowering-unittest.cc b/test/unittests/compiler/js-typed-lowering-unittest.cc |
index 3da4bc71683a75e82c19ee7dedeadfd066c5d3c5..81b48a64d69c6c88c847bde59f989580b9f7fcbf 100644 |
--- a/test/unittests/compiler/js-typed-lowering-unittest.cc |
+++ b/test/unittests/compiler/js-typed-lowering-unittest.cc |
@@ -69,6 +69,46 @@ class JSTypedLoweringTest : public TypedGraphTest { |
// ----------------------------------------------------------------------------- |
+// JSToBoolean |
+ |
+ |
+TEST_F(JSTypedLoweringTest, JSToBooleanWithString) { |
+ Node* input = Parameter(Type::String()); |
+ Node* context = UndefinedConstant(); |
+ Node* effect = graph()->start(); |
+ Node* control = graph()->start(); |
+ |
+ Reduction r = Reduce(graph()->NewNode(javascript()->ToBoolean(), input, |
+ context, effect, control)); |
+ ASSERT_TRUE(r.Changed()); |
+ EXPECT_THAT(r.replacement(), |
+ IsBooleanNot(IsNumberEqual( |
+ IsLoadField(AccessBuilder::ForStringLength(), input, |
+ graph()->start(), graph()->start()), |
+ IsNumberConstant(0)))); |
+} |
+ |
+ |
+TEST_F(JSTypedLoweringTest, JSToBooleanWithOrderedNumberAndBoolean) { |
+ Node* p0 = Parameter(Type::OrderedNumber(), 0); |
+ Node* p1 = Parameter(Type::Boolean(), 1); |
+ Node* context = UndefinedConstant(); |
+ Node* effect = graph()->start(); |
+ Node* control = graph()->start(); |
+ |
+ Reduction r = Reduce(graph()->NewNode( |
+ javascript()->ToBoolean(), |
+ graph()->NewNode(common()->Phi(kMachAnyTagged, 2), p0, p1, control), |
+ context, effect, control)); |
+ ASSERT_TRUE(r.Changed()); |
+ EXPECT_THAT( |
+ r.replacement(), |
+ IsPhi(kMachAnyTagged, |
+ IsBooleanNot(IsNumberEqual(p0, IsNumberConstant(0))), p1, control)); |
+} |
+ |
+ |
+// ----------------------------------------------------------------------------- |
// JSLoadProperty |