summaryrefslogtreecommitdiff
path: root/unittests/Tooling/StencilTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'unittests/Tooling/StencilTest.cpp')
-rw-r--r--unittests/Tooling/StencilTest.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/unittests/Tooling/StencilTest.cpp b/unittests/Tooling/StencilTest.cpp
index cc0e8facca..2202693f02 100644
--- a/unittests/Tooling/StencilTest.cpp
+++ b/unittests/Tooling/StencilTest.cpp
@@ -29,6 +29,7 @@ using stencil::access;
using stencil::cat;
using stencil::dPrint;
using stencil::ifBound;
+using stencil::run;
using stencil::text;
// Create a valid translation-unit from a statement.
@@ -283,6 +284,15 @@ TEST_F(StencilTest, AccessOpImplicitThis) {
EXPECT_THAT_EXPECTED(Stencil.eval(StmtMatch->Result), HasValue("field"));
}
+TEST_F(StencilTest, RunOp) {
+ StringRef Id = "id";
+ auto SimpleFn = [Id](const MatchResult &R) {
+ return std::string(R.Nodes.getNodeAs<Stmt>(Id) != nullptr ? "Bound"
+ : "Unbound");
+ };
+ testExpr(Id, "3;", cat(run(SimpleFn)), "Bound");
+}
+
TEST(StencilEqualityTest, Equality) {
auto Lhs = cat("foo", dPrint("dprint_id"));
auto Rhs = cat("foo", dPrint("dprint_id"));
@@ -307,4 +317,12 @@ TEST(StencilEqualityTest, InEqualitySelection) {
auto S2 = cat(node("node"));
EXPECT_NE(S1, S2);
}
+
+// `run` is opaque.
+TEST(StencilEqualityTest, InEqualityRun) {
+ auto F = [](const MatchResult &R) { return "foo"; };
+ auto S1 = cat(run(F));
+ auto S2 = cat(run(F));
+ EXPECT_NE(S1, S2);
+}
} // namespace