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 781cf4c2c65fdad1350258e64e470833e47100a9..d347c4139b35cfa9f6f07d94530fee164ab9580d 100644 |
--- a/test/unittests/compiler/js-typed-lowering-unittest.cc |
+++ b/test/unittests/compiler/js-typed-lowering-unittest.cc |
@@ -184,13 +184,25 @@ TEST_F(JSTypedLoweringTest, JSUnaryNotWithNonZeroPlainNumber) { |
} |
+TEST_F(JSTypedLoweringTest, JSUnaryNotWithString) { |
+ Node* input = Parameter(Type::String(), 0); |
+ Node* context = Parameter(Type::Any(), 1); |
+ Reduction r = |
+ Reduce(graph()->NewNode(javascript()->UnaryNot(), input, context)); |
+ ASSERT_TRUE(r.Changed()); |
+ EXPECT_THAT(r.replacement(), |
+ IsNumberEqual(IsLoadField(AccessBuilder::ForStringLength(), input, |
+ graph()->start(), graph()->start()), |
+ IsNumberConstant(0.0))); |
+} |
+ |
+ |
TEST_F(JSTypedLoweringTest, JSUnaryNotWithAny) { |
Node* input = Parameter(Type::Any(), 0); |
Node* context = Parameter(Type::Any(), 1); |
Reduction r = |
Reduce(graph()->NewNode(javascript()->UnaryNot(), input, context)); |
- ASSERT_TRUE(r.Changed()); |
- EXPECT_THAT(r.replacement(), IsBooleanNot(IsAnyToBoolean(input))); |
+ ASSERT_FALSE(r.Changed()); |
} |
@@ -360,13 +372,37 @@ TEST_F(JSTypedLoweringTest, JSToBooleanWithNonZeroPlainNumber) { |
} |
+TEST_F(JSTypedLoweringTest, JSToBooleanWithOrderedNumber) { |
+ Node* input = Parameter(Type::OrderedNumber(), 0); |
+ Node* context = Parameter(Type::Any(), 1); |
+ Reduction r = |
+ Reduce(graph()->NewNode(javascript()->ToBoolean(), input, context)); |
+ ASSERT_TRUE(r.Changed()); |
+ EXPECT_THAT(r.replacement(), |
+ IsBooleanNot(IsNumberEqual(input, IsNumberConstant(0.0)))); |
+} |
+ |
+ |
+TEST_F(JSTypedLoweringTest, JSToBooleanWithString) { |
+ Node* input = Parameter(Type::String(), 0); |
+ Node* context = Parameter(Type::Any(), 1); |
+ Reduction r = |
+ Reduce(graph()->NewNode(javascript()->ToBoolean(), input, context)); |
+ ASSERT_TRUE(r.Changed()); |
+ EXPECT_THAT( |
+ r.replacement(), |
+ IsNumberLessThan(IsNumberConstant(0.0), |
+ IsLoadField(AccessBuilder::ForStringLength(), input, |
+ graph()->start(), graph()->start()))); |
+} |
+ |
+ |
TEST_F(JSTypedLoweringTest, JSToBooleanWithAny) { |
Node* input = Parameter(Type::Any(), 0); |
Node* context = Parameter(Type::Any(), 1); |
Reduction r = |
Reduce(graph()->NewNode(javascript()->ToBoolean(), input, context)); |
- ASSERT_TRUE(r.Changed()); |
- EXPECT_THAT(r.replacement(), IsAnyToBoolean(input)); |
+ ASSERT_FALSE(r.Changed()); |
} |