diff options
Diffstat (limited to 'clang/unittests/Interpreter')
-rw-r--r-- | clang/unittests/Interpreter/InterpreterTest.cpp | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/clang/unittests/Interpreter/InterpreterTest.cpp b/clang/unittests/Interpreter/InterpreterTest.cpp index b97f5ae..768058b 100644 --- a/clang/unittests/Interpreter/InterpreterTest.cpp +++ b/clang/unittests/Interpreter/InterpreterTest.cpp @@ -22,6 +22,8 @@ #include "clang/Sema/Lookup.h" #include "clang/Sema/Sema.h" +#include "llvm/TargetParser/Host.h" + #include "gmock/gmock.h" #include "gtest/gtest.h" @@ -158,12 +160,12 @@ TEST_F(InterpreterTest, UndoCommand) { // Fail to undo. auto Err1 = Interp->Undo(); - EXPECT_EQ("Operation failed. Too many undos", + EXPECT_EQ("Operation failed. No input left to undo", llvm::toString(std::move(Err1))); auto Err2 = Interp->Parse("int foo = 42;"); EXPECT_TRUE(!!Err2); auto Err3 = Interp->Undo(2); - EXPECT_EQ("Operation failed. Too many undos", + EXPECT_EQ("Operation failed. Wanted to undo 2 inputs, only have 1.", llvm::toString(std::move(Err3))); // Succeed to undo. @@ -389,6 +391,26 @@ TEST_F(InterpreterTest, Value) { EXPECT_TRUE(V9.getType()->isMemberFunctionPointerType()); EXPECT_EQ(V9.getKind(), Value::K_PtrOrObj); EXPECT_TRUE(V9.isManuallyAlloc()); + + Value V10; + llvm::cantFail(Interp->ParseAndExecute( + "enum D : unsigned int {Zero = 0, One}; One", &V10)); + + std::string prettyType; + llvm::raw_string_ostream OSType(prettyType); + V10.printType(OSType); + EXPECT_STREQ(prettyType.c_str(), "D"); + + // FIXME: We should print only the value or the constant not the type. + std::string prettyData; + llvm::raw_string_ostream OSData(prettyData); + V10.printData(OSData); + EXPECT_STREQ(prettyData.c_str(), "(One) : unsigned int 1"); + + std::string prettyPrint; + llvm::raw_string_ostream OSPrint(prettyPrint); + V10.print(OSPrint); + EXPECT_STREQ(prettyPrint.c_str(), "(D) (One) : unsigned int 1\n"); } TEST_F(InterpreterTest, TranslationUnit_CanonicalDecl) { |