Index: test/cctest/compiler/test-node.cc |
diff --git a/test/cctest/compiler/test-node.cc b/test/cctest/compiler/test-node.cc |
index d317c3877c82866356317581af2ceb1914ffed2c..e2aacf3100766bc4ab4504a780fd84b6b8142706 100644 |
--- a/test/cctest/compiler/test-node.cc |
+++ b/test/cctest/compiler/test-node.cc |
@@ -320,6 +320,80 @@ TEST(Inputs) { |
CHECK_USES(n4, n3, n3, n5); |
} |
+TEST(InsertInputs) { |
+ base::AccountingAllocator allocator; |
+ Zone zone(&allocator); |
+ Graph graph(&zone); |
+ |
+ Node* n0 = graph.NewNode(&dummy_operator0); |
+ Node* n1 = graph.NewNode(&dummy_operator1, n0); |
+ Node* n2 = graph.NewNode(&dummy_operator1, n0); |
+ |
+ { |
+ Node* node = graph.NewNode(&dummy_operator1, n0); |
+ node->InsertInputs(graph.zone(), 0, 1); |
+ node->ReplaceInput(0, n1); |
+ CHECK_INPUTS(node, n1, n0); |
+ } |
+ { |
+ Node* node = graph.NewNode(&dummy_operator1, n0); |
+ node->InsertInputs(graph.zone(), 0, 2); |
+ node->ReplaceInput(0, node); |
+ node->ReplaceInput(1, n2); |
+ CHECK_INPUTS(node, node, n2, n0); |
+ } |
+ { |
+ Node* node = graph.NewNode(&dummy_operator3, n0, n1, n2); |
+ node->InsertInputs(graph.zone(), 0, 1); |
+ node->ReplaceInput(0, node); |
+ CHECK_INPUTS(node, node, n0, n1, n2); |
+ } |
+ { |
+ Node* node = graph.NewNode(&dummy_operator3, n0, n1, n2); |
+ node->InsertInputs(graph.zone(), 1, 1); |
+ node->ReplaceInput(1, node); |
+ CHECK_INPUTS(node, n0, node, n1, n2); |
+ } |
+ { |
+ Node* node = graph.NewNode(&dummy_operator3, n0, n1, n2); |
+ node->InsertInputs(graph.zone(), 2, 1); |
+ node->ReplaceInput(2, node); |
+ CHECK_INPUTS(node, n0, n1, node, n2); |
+ } |
+ { |
+ Node* node = graph.NewNode(&dummy_operator3, n0, n1, n2); |
+ node->InsertInputs(graph.zone(), 2, 1); |
+ node->ReplaceInput(2, node); |
+ CHECK_INPUTS(node, n0, n1, node, n2); |
+ } |
+ { |
+ Node* node = graph.NewNode(&dummy_operator3, n0, n1, n2); |
+ node->InsertInputs(graph.zone(), 0, 4); |
+ node->ReplaceInput(0, node); |
+ node->ReplaceInput(1, node); |
+ node->ReplaceInput(2, node); |
+ node->ReplaceInput(3, node); |
+ CHECK_INPUTS(node, node, node, node, node, n0, n1, n2); |
+ } |
+ { |
+ Node* node = graph.NewNode(&dummy_operator3, n0, n1, n2); |
+ node->InsertInputs(graph.zone(), 1, 4); |
+ node->ReplaceInput(1, node); |
+ node->ReplaceInput(2, node); |
+ node->ReplaceInput(3, node); |
+ node->ReplaceInput(4, node); |
+ CHECK_INPUTS(node, n0, node, node, node, node, n1, n2); |
+ } |
+ { |
+ Node* node = graph.NewNode(&dummy_operator3, n0, n1, n2); |
+ node->InsertInputs(graph.zone(), 2, 4); |
+ node->ReplaceInput(2, node); |
+ node->ReplaceInput(3, node); |
+ node->ReplaceInput(4, node); |
+ node->ReplaceInput(5, node); |
+ CHECK_INPUTS(node, n0, n1, node, node, node, node, n2); |
+ } |
+} |
TEST(RemoveInput) { |
base::AccountingAllocator allocator; |