Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1027)

Unified Diff: test/unittests/compiler/node-properties-unittest.cc

Issue 935033004: Introduce and test NodeProperties::CollectControlProjections. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/scheduler.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/unittests/compiler/node-properties-unittest.cc
diff --git a/test/unittests/compiler/node-properties-unittest.cc b/test/unittests/compiler/node-properties-unittest.cc
index d6d80738160963f50222cab39ae127324a32afd3..bb471bd01e5f80f270a34dd30d694c1c3f1e6d00 100644
--- a/test/unittests/compiler/node-properties-unittest.cc
+++ b/test/unittests/compiler/node-properties-unittest.cc
@@ -7,6 +7,7 @@
#include "test/unittests/test-utils.h"
#include "testing/gmock/include/gmock/gmock.h"
+using testing::AnyOf;
using testing::IsNull;
namespace v8 {
@@ -27,6 +28,32 @@ TEST_F(NodePropertiesTest, FindProjection) {
EXPECT_THAT(NodeProperties::FindProjection(start, 1234567890), IsNull());
}
+
+TEST_F(NodePropertiesTest, CollectControlProjections_Branch) {
+ Node* result[2];
+ CommonOperatorBuilder common(zone());
+ Node* branch = Node::New(zone(), 1, common.Branch(), 0, nullptr, false);
+ Node* if_false = Node::New(zone(), 2, common.IfFalse(), 1, &branch, false);
+ Node* if_true = Node::New(zone(), 3, common.IfTrue(), 1, &branch, false);
+ NodeProperties::CollectControlProjections(branch, result, arraysize(result));
+ EXPECT_EQ(if_true, result[0]);
+ EXPECT_EQ(if_false, result[1]);
+}
+
+
+TEST_F(NodePropertiesTest, CollectControlProjections_Switch) {
+ Node* result[3];
+ CommonOperatorBuilder common(zone());
+ Node* sw = Node::New(zone(), 1, common.Switch(3), 0, nullptr, false);
+ Node* if_default = Node::New(zone(), 2, common.IfDefault(), 1, &sw, false);
+ Node* if_value1 = Node::New(zone(), 3, common.IfValue(1), 1, &sw, false);
+ Node* if_value2 = Node::New(zone(), 4, common.IfValue(2), 1, &sw, false);
+ NodeProperties::CollectControlProjections(sw, result, arraysize(result));
+ EXPECT_THAT(result[0], AnyOf(if_value1, if_value2));
+ EXPECT_THAT(result[1], AnyOf(if_value1, if_value2));
+ EXPECT_EQ(if_default, result[2]);
+}
+
} // namespace compiler
} // namespace internal
} // namespace v8
« no previous file with comments | « src/compiler/scheduler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698