Skip to content

Commit c7c0903

Browse files
author
kr-2003
committed
added undo test for n > 1
1 parent 55d3089 commit c7c0903

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

lib/Interpreter/CppInterOp.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3618,8 +3618,6 @@ namespace Cpp {
36183618

36193619
int Undo(unsigned N) {
36203620
#ifdef CPPINTEROP_USE_CLING
3621-
llvm::logAllUnhandledErrors(Undo(N), llvm::errs(),
3622-
"Undo not implemented in Cling");
36233621
return compat::Interpreter::kFailure;
36243622
#else
36253623
return getInterp().undo(N);

unittests/CppInterOp/FunctionReflectionTest.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1261,7 +1261,28 @@ TEST(FunctionReflectionTest, UndoTest) {
12611261
EXPECT_STREQ(cerrs.c_str(), "");
12621262
Cpp::Undo();
12631263
testing::internal::CaptureStderr();
1264+
Cpp::Process("int y = x;");
1265+
cerrs = testing::internal::GetCapturedStderr();
1266+
EXPECT_STREQ(
1267+
cerrs.c_str(),
1268+
"In file included from <<< inputs >>>:1:\ninput_line_2:1:9: error: use "
1269+
"of undeclared identifier 'x'\n 1 | int y = x;\n | "
1270+
"^\nFailed to parse via ::process:Parsing failed.\n");
1271+
testing::internal::CaptureStderr();
12641272
Cpp::Process("int x = 10;");
12651273
cerrs = testing::internal::GetCapturedStderr();
12661274
EXPECT_STREQ(cerrs.c_str(), "");
1275+
testing::internal::CaptureStderr();
1276+
Cpp::Process("int y = 10;");
1277+
cerrs = testing::internal::GetCapturedStderr();
1278+
EXPECT_STREQ(cerrs.c_str(), "");
1279+
Cpp::Undo(2);
1280+
testing::internal::CaptureStderr();
1281+
Cpp::Process("int x = 20;");
1282+
cerrs = testing::internal::GetCapturedStderr();
1283+
EXPECT_STREQ(cerrs.c_str(), "");
1284+
testing::internal::CaptureStderr();
1285+
Cpp::Process("int y = 20;");
1286+
cerrs = testing::internal::GetCapturedStderr();
1287+
EXPECT_STREQ(cerrs.c_str(), "");
12671288
}

0 commit comments

Comments
 (0)