OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "test/compiler-unittests/common-operator-unittest.h" | 5 #include "test/compiler-unittests/common-operator-unittest.h" |
6 | 6 |
7 #include "src/compiler/operator-properties-inl.h" | 7 #include "src/compiler/operator-properties-inl.h" |
8 | 8 |
9 namespace v8 { | 9 namespace v8 { |
10 namespace internal { | 10 namespace internal { |
11 namespace compiler { | 11 namespace compiler { |
12 | 12 |
| 13 static const int kArguments[] = {1, 5, 6, 42, 100, 10000, kMaxInt}; |
| 14 |
| 15 |
13 CommonOperatorTest::CommonOperatorTest() : common_(zone()) {} | 16 CommonOperatorTest::CommonOperatorTest() : common_(zone()) {} |
14 | 17 |
15 | 18 |
16 CommonOperatorTest::~CommonOperatorTest() {} | 19 CommonOperatorTest::~CommonOperatorTest() {} |
17 | 20 |
18 | 21 |
19 TEST_F(CommonOperatorTest, ControlEffect) { | 22 TEST_F(CommonOperatorTest, ControlEffect) { |
20 Operator* op = common()->ControlEffect(); | 23 Operator* op = common()->ControlEffect(); |
21 EXPECT_EQ(1, OperatorProperties::GetControlInputCount(op)); | 24 EXPECT_EQ(1, OperatorProperties::GetControlInputCount(op)); |
22 EXPECT_EQ(1, OperatorProperties::GetTotalInputCount(op)); | 25 EXPECT_EQ(1, OperatorProperties::GetTotalInputCount(op)); |
23 EXPECT_EQ(0, OperatorProperties::GetControlOutputCount(op)); | 26 EXPECT_EQ(0, OperatorProperties::GetControlOutputCount(op)); |
24 EXPECT_EQ(1, OperatorProperties::GetEffectOutputCount(op)); | 27 EXPECT_EQ(1, OperatorProperties::GetEffectOutputCount(op)); |
25 EXPECT_EQ(0, OperatorProperties::GetValueOutputCount(op)); | 28 EXPECT_EQ(0, OperatorProperties::GetValueOutputCount(op)); |
26 } | 29 } |
27 | 30 |
28 | 31 |
| 32 TEST_F(CommonOperatorTest, ValueEffect) { |
| 33 TRACED_FOREACH(int, arguments, kArguments) { |
| 34 Operator* op = common()->ValueEffect(arguments); |
| 35 EXPECT_EQ(arguments, OperatorProperties::GetValueInputCount(op)); |
| 36 EXPECT_EQ(arguments, OperatorProperties::GetTotalInputCount(op)); |
| 37 EXPECT_EQ(0, OperatorProperties::GetControlOutputCount(op)); |
| 38 EXPECT_EQ(1, OperatorProperties::GetEffectOutputCount(op)); |
| 39 EXPECT_EQ(0, OperatorProperties::GetValueOutputCount(op)); |
| 40 } |
| 41 } |
| 42 |
| 43 |
29 TEST_F(CommonOperatorTest, Finish) { | 44 TEST_F(CommonOperatorTest, Finish) { |
30 static const int kArguments[] = {1, 5, 6, 42, 100, 10000, kMaxInt}; | |
31 TRACED_FOREACH(int, arguments, kArguments) { | 45 TRACED_FOREACH(int, arguments, kArguments) { |
32 Operator* op = common()->Finish(arguments); | 46 Operator* op = common()->Finish(arguments); |
33 EXPECT_EQ(1, OperatorProperties::GetValueInputCount(op)); | 47 EXPECT_EQ(1, OperatorProperties::GetValueInputCount(op)); |
34 EXPECT_EQ(arguments, OperatorProperties::GetEffectInputCount(op)); | 48 EXPECT_EQ(arguments, OperatorProperties::GetEffectInputCount(op)); |
35 EXPECT_EQ(arguments + 1, OperatorProperties::GetTotalInputCount(op)); | 49 EXPECT_EQ(arguments + 1, OperatorProperties::GetTotalInputCount(op)); |
36 EXPECT_EQ(0, OperatorProperties::GetControlOutputCount(op)); | 50 EXPECT_EQ(0, OperatorProperties::GetControlOutputCount(op)); |
37 EXPECT_EQ(0, OperatorProperties::GetEffectOutputCount(op)); | 51 EXPECT_EQ(0, OperatorProperties::GetEffectOutputCount(op)); |
38 EXPECT_EQ(1, OperatorProperties::GetValueOutputCount(op)); | 52 EXPECT_EQ(1, OperatorProperties::GetValueOutputCount(op)); |
39 } | 53 } |
40 } | 54 } |
41 | 55 |
42 } // namespace compiler | 56 } // namespace compiler |
43 } // namespace internal | 57 } // namespace internal |
44 } // namespace v8 | 58 } // namespace v8 |
OLD | NEW |