| 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 61943b1762ce5a5b05282f19cfedbeffbf0db6ae..2c03d885c6b6c50657e7f09eaa9aa15692ad4a5f 100644
|
| --- a/test/unittests/compiler/js-typed-lowering-unittest.cc
|
| +++ b/test/unittests/compiler/js-typed-lowering-unittest.cc
|
| @@ -78,14 +78,79 @@ class JSTypedLoweringTest : public TypedGraphTest {
|
| // JSToBoolean
|
|
|
|
|
| +TEST_F(JSTypedLoweringTest, JSToBooleanWithBoolean) {
|
| + Node* input = Parameter(Type::Boolean());
|
| + Node* context = UndefinedConstant();
|
| +
|
| + Reduction r =
|
| + Reduce(graph()->NewNode(javascript()->ToBoolean(), input, context));
|
| + ASSERT_TRUE(r.Changed());
|
| + EXPECT_EQ(input, r.replacement());
|
| +}
|
| +
|
| +
|
| +TEST_F(JSTypedLoweringTest, JSToBooleanWithUndefined) {
|
| + Node* input = Parameter(Type::Undefined());
|
| + Node* context = UndefinedConstant();
|
| +
|
| + Reduction r =
|
| + Reduce(graph()->NewNode(javascript()->ToBoolean(), input, context));
|
| + ASSERT_TRUE(r.Changed());
|
| + EXPECT_THAT(r.replacement(), IsFalseConstant());
|
| +}
|
| +
|
| +
|
| +TEST_F(JSTypedLoweringTest, JSToBooleanWithNull) {
|
| + Node* input = Parameter(Type::Null());
|
| + Node* context = UndefinedConstant();
|
| +
|
| + Reduction r =
|
| + Reduce(graph()->NewNode(javascript()->ToBoolean(), input, context));
|
| + ASSERT_TRUE(r.Changed());
|
| + EXPECT_THAT(r.replacement(), IsFalseConstant());
|
| +}
|
| +
|
| +
|
| +TEST_F(JSTypedLoweringTest, JSToBooleanWithDetectableReceiver) {
|
| + Node* input = Parameter(Type::DetectableReceiver());
|
| + Node* context = UndefinedConstant();
|
| +
|
| + Reduction r =
|
| + Reduce(graph()->NewNode(javascript()->ToBoolean(), input, context));
|
| + ASSERT_TRUE(r.Changed());
|
| + EXPECT_THAT(r.replacement(), IsTrueConstant());
|
| +}
|
| +
|
| +
|
| +TEST_F(JSTypedLoweringTest, JSToBooleanWithUndetectable) {
|
| + Node* input = Parameter(Type::Undetectable());
|
| + Node* context = UndefinedConstant();
|
| +
|
| + Reduction r =
|
| + Reduce(graph()->NewNode(javascript()->ToBoolean(), input, context));
|
| + ASSERT_TRUE(r.Changed());
|
| + EXPECT_THAT(r.replacement(), IsFalseConstant());
|
| +}
|
| +
|
| +
|
| +TEST_F(JSTypedLoweringTest, JSToBooleanWithOrderedNumber) {
|
| + Node* input = Parameter(Type::OrderedNumber());
|
| + Node* context = UndefinedConstant();
|
| +
|
| + Reduction r =
|
| + Reduce(graph()->NewNode(javascript()->ToBoolean(), input, context));
|
| + ASSERT_TRUE(r.Changed());
|
| + EXPECT_THAT(r.replacement(),
|
| + IsBooleanNot(IsNumberEqual(input, IsNumberConstant(0))));
|
| +}
|
| +
|
| +
|
| 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));
|
| + Reduction r =
|
| + Reduce(graph()->NewNode(javascript()->ToBoolean(), input, context));
|
| ASSERT_TRUE(r.Changed());
|
| EXPECT_THAT(r.replacement(),
|
| IsBooleanNot(IsNumberEqual(
|
| @@ -95,17 +160,16 @@ TEST_F(JSTypedLoweringTest, JSToBooleanWithString) {
|
| }
|
|
|
|
|
| -TEST_F(JSTypedLoweringTest, JSToBooleanWithOrderedNumberAndBoolean) {
|
| +TEST_F(JSTypedLoweringTest, JSToBooleanWithPhi) {
|
| 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));
|
| + context));
|
| ASSERT_TRUE(r.Changed());
|
| EXPECT_THAT(
|
| r.replacement(),
|
| @@ -114,6 +178,24 @@ TEST_F(JSTypedLoweringTest, JSToBooleanWithOrderedNumberAndBoolean) {
|
| }
|
|
|
|
|
| +TEST_F(JSTypedLoweringTest, JSToBooleanWithSelect) {
|
| + Node* p0 = Parameter(Type::Boolean(), 0);
|
| + Node* p1 = Parameter(Type::DetectableReceiver(), 1);
|
| + Node* p2 = Parameter(Type::OrderedNumber(), 2);
|
| + Node* context = UndefinedConstant();
|
| +
|
| + Reduction r = Reduce(graph()->NewNode(
|
| + javascript()->ToBoolean(),
|
| + graph()->NewNode(common()->Select(kMachAnyTagged, BranchHint::kTrue), p0,
|
| + p1, p2),
|
| + context));
|
| + ASSERT_TRUE(r.Changed());
|
| + EXPECT_THAT(r.replacement(),
|
| + IsSelect(kMachAnyTagged, p0, IsTrueConstant(),
|
| + IsBooleanNot(IsNumberEqual(p2, IsNumberConstant(0)))));
|
| +}
|
| +
|
| +
|
| // -----------------------------------------------------------------------------
|
| // JSStrictEqual
|
|
|
|
|