Skip to content

Commit 15d8600

Browse files
committed
Add tests for Cpp::Evaluate that use more runtime symbols
1 parent adfd4a4 commit 15d8600

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

unittests/CppInterOp/InterpreterTest.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,38 @@ TEST(InterpreterTest, Evaluate) {
8080
EXPECT_FALSE(HadError) ;
8181
}
8282

83+
TEST(InterpreterTest, EvaluateExtensive) {
84+
#ifdef EMSCRIPTEN
85+
GTEST_SKIP() << "Test fails for Emscipten builds";
86+
#endif
87+
#ifdef _WIN32
88+
GTEST_SKIP() << "Disabled on Windows. Needs fixing.";
89+
#endif
90+
if (llvm::sys::RunningOnValgrind())
91+
GTEST_SKIP() << "XFAIL due to Valgrind report";
92+
Cpp::CreateInterpreter();
93+
EXPECT_TRUE(Cpp::Evaluate("__cplusplus") == 201402);
94+
95+
bool HadError;
96+
EXPECT_TRUE(Cpp::Evaluate("#error", &HadError) == (intptr_t)~0UL);
97+
EXPECT_TRUE(HadError);
98+
// for llvm < 19 this tests all different overloads of __clang_Interpreter_SetValueNoAlloc
99+
EXPECT_EQ(Cpp::Evaluate("int i = 11; ++i", &HadError), 12);
100+
EXPECT_FALSE(HadError) ;
101+
EXPECT_EQ(Cpp::Evaluate("double a = 12.; a", &HadError), 12.);
102+
EXPECT_FALSE(HadError) ;
103+
EXPECT_EQ(Cpp::Evaluate("float b = 13.; b", &HadError), 13.);
104+
EXPECT_FALSE(HadError) ;
105+
EXPECT_EQ(Cpp::Evaluate("long double c = 14.; c", &HadError), 14.);
106+
EXPECT_FALSE(HadError) ;
107+
EXPECT_EQ(Cpp::Evaluate("long double d = 15.; d", &HadError), 15.);
108+
EXPECT_FALSE(HadError);
109+
EXPECT_EQ(Cpp::Evaluate("unsigned long long e = 16; e", &HadError), 16);
110+
EXPECT_FALSE(HadError) ;
111+
EXPECT_NE(Cpp::Evaluate("struct S{} s; s", &HadError), (intptr_t)~0UL);
112+
EXPECT_FALSE(HadError) ;
113+
}
114+
83115
TEST(InterpreterTest, DeleteInterpreter) {
84116
auto* I1 = Cpp::CreateInterpreter();
85117
auto* I2 = Cpp::CreateInterpreter();

0 commit comments

Comments
 (0)