Index: cfe/trunk/unittests/Tooling/StencilTest.cpp =================================================================== --- cfe/trunk/unittests/Tooling/StencilTest.cpp +++ cfe/trunk/unittests/Tooling/StencilTest.cpp @@ -31,23 +31,6 @@ using stencil::ifBound; using stencil::text; -// In tests, we can't directly match on llvm::Expected since its accessors -// mutate the object. So, we collapse it to an Optional. -static llvm::Optional toOptional(llvm::Expected V) { - if (V) - return *V; - ADD_FAILURE() << "Losing error in conversion to IsSomething: " - << llvm::toString(V.takeError()); - return llvm::None; -} - -// A very simple matcher for llvm::Optional values. -MATCHER_P(IsSomething, ValueMatcher, "") { - if (!arg) - return false; - return ::testing::ExplainMatchResult(ValueMatcher, *arg, result_listener); -} - // Create a valid translation-unit from a statement. static std::string wrapSnippet(StringRef StatementCode) { return ("struct S { int field; }; auto stencil_test_snippet = []{" + @@ -151,8 +134,8 @@ // Invert the if-then-else. auto Stencil = cat("if (!", node(Condition), ") ", statement(Else), " else ", statement(Then)); - EXPECT_THAT(toOptional(Stencil.eval(StmtMatch->Result)), - IsSomething(Eq("if (!true) return 0; else return 1;"))); + EXPECT_THAT_EXPECTED(Stencil.eval(StmtMatch->Result), + HasValue("if (!true) return 0; else return 1;")); } TEST_F(StencilTest, SingleStatementCallOperator) { @@ -170,8 +153,8 @@ // Invert the if-then-else. Stencil S = cat("if (!", node(Condition), ") ", statement(Else), " else ", statement(Then)); - EXPECT_THAT(toOptional(S(StmtMatch->Result)), - IsSomething(Eq("if (!true) return 0; else return 1;"))); + EXPECT_THAT_EXPECTED(S(StmtMatch->Result), + HasValue("if (!true) return 0; else return 1;")); } TEST_F(StencilTest, UnboundNode) {