OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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 "src/compiler/node.h" | 5 #include "src/compiler/node.h" |
6 #include "src/compiler/operator.h" | 6 #include "src/compiler/operator.h" |
7 #include "test/unittests/test-utils.h" | 7 #include "test/unittests/test-utils.h" |
8 #include "testing/gmock-support.h" | 8 #include "testing/gmock-support.h" |
9 | 9 |
10 using testing::ElementsAre; | 10 using testing::ElementsAre; |
(...skipping 30 matching lines...) Expand all Loading... |
41 EXPECT_EQ(kOpcode0, node->opcode()); | 41 EXPECT_EQ(kOpcode0, node->opcode()); |
42 } | 42 } |
43 | 43 |
44 | 44 |
45 TEST_F(NodeTest, NewWithInputs) { | 45 TEST_F(NodeTest, NewWithInputs) { |
46 Node* n0 = Node::New(zone(), 0, &kOp0, 0, nullptr, false); | 46 Node* n0 = Node::New(zone(), 0, &kOp0, 0, nullptr, false); |
47 EXPECT_EQ(0, n0->UseCount()); | 47 EXPECT_EQ(0, n0->UseCount()); |
48 EXPECT_EQ(0, n0->InputCount()); | 48 EXPECT_EQ(0, n0->InputCount()); |
49 Node* n1 = Node::New(zone(), 1, &kOp1, 1, &n0, false); | 49 Node* n1 = Node::New(zone(), 1, &kOp1, 1, &n0, false); |
50 EXPECT_EQ(1, n0->UseCount()); | 50 EXPECT_EQ(1, n0->UseCount()); |
51 EXPECT_EQ(n1, n0->UseAt(0)); | 51 EXPECT_THAT(n0->uses(), UnorderedElementsAre(n1)); |
52 EXPECT_EQ(0, n1->UseCount()); | 52 EXPECT_EQ(0, n1->UseCount()); |
53 EXPECT_EQ(1, n1->InputCount()); | 53 EXPECT_EQ(1, n1->InputCount()); |
54 EXPECT_EQ(n0, n1->InputAt(0)); | 54 EXPECT_EQ(n0, n1->InputAt(0)); |
55 Node* n0_n1[] = {n0, n1}; | 55 Node* n0_n1[] = {n0, n1}; |
56 Node* n2 = Node::New(zone(), 2, &kOp2, 2, n0_n1, false); | 56 Node* n2 = Node::New(zone(), 2, &kOp2, 2, n0_n1, false); |
57 EXPECT_EQ(2, n0->UseCount()); | 57 EXPECT_EQ(2, n0->UseCount()); |
58 EXPECT_EQ(n1, n0->UseAt(0)); | 58 EXPECT_THAT(n0->uses(), UnorderedElementsAre(n1, n2)); |
59 EXPECT_EQ(n2, n0->UseAt(1)); | 59 EXPECT_THAT(n1->uses(), UnorderedElementsAre(n2)); |
60 EXPECT_EQ(2, n2->InputCount()); | 60 EXPECT_EQ(2, n2->InputCount()); |
61 EXPECT_EQ(n0, n2->InputAt(0)); | 61 EXPECT_EQ(n0, n2->InputAt(0)); |
62 EXPECT_EQ(n1, n2->InputAt(1)); | 62 EXPECT_EQ(n1, n2->InputAt(1)); |
63 } | 63 } |
64 | 64 |
65 | 65 |
66 TEST_F(NodeTest, InputIteratorEmpty) { | 66 TEST_F(NodeTest, InputIteratorEmpty) { |
67 Node* node = Node::New(zone(), 0, &kOp0, 0, nullptr, false); | 67 Node* node = Node::New(zone(), 0, &kOp0, 0, nullptr, false); |
68 EXPECT_EQ(node->inputs().begin(), node->inputs().end()); | 68 EXPECT_EQ(node->inputs().begin(), node->inputs().end()); |
69 } | 69 } |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 EXPECT_THAT(node->inputs(), ElementsAre(n0, n1, n0)); | 161 EXPECT_THAT(node->inputs(), ElementsAre(n0, n1, n0)); |
162 node->AppendInput(zone(), n0); | 162 node->AppendInput(zone(), n0); |
163 EXPECT_THAT(node->inputs(), ElementsAre(n0, n1, n0, n0)); | 163 EXPECT_THAT(node->inputs(), ElementsAre(n0, n1, n0, n0)); |
164 node->AppendInput(zone(), n1); | 164 node->AppendInput(zone(), n1); |
165 EXPECT_THAT(node->inputs(), ElementsAre(n0, n1, n0, n0, n1)); | 165 EXPECT_THAT(node->inputs(), ElementsAre(n0, n1, n0, n0, n1)); |
166 } | 166 } |
167 | 167 |
168 } // namespace compiler | 168 } // namespace compiler |
169 } // namespace internal | 169 } // namespace internal |
170 } // namespace v8 | 170 } // namespace v8 |
OLD | NEW |