Skip to content

Commit bd5ce84

Browse files
kr-2003anutosh491
authored andcommitted
added undo test for n > 1
1 parent da9cfda commit bd5ce84

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
@@ -3674,8 +3674,6 @@ namespace Cpp {
36743674

36753675
int Undo(unsigned N) {
36763676
#ifdef CPPINTEROP_USE_CLING
3677-
llvm::logAllUnhandledErrors(Undo(N), llvm::errs(),
3678-
"Undo not implemented in Cling");
36793677
return compat::Interpreter::kFailure;
36803678
#else
36813679
return getInterp().undo(N);

unittests/CppInterOp/FunctionReflectionTest.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1527,7 +1527,28 @@ TEST(FunctionReflectionTest, UndoTest) {
15271527
EXPECT_STREQ(cerrs.c_str(), "");
15281528
Cpp::Undo();
15291529
testing::internal::CaptureStderr();
1530+
Cpp::Process("int y = x;");
1531+
cerrs = testing::internal::GetCapturedStderr();
1532+
EXPECT_STREQ(
1533+
cerrs.c_str(),
1534+
"In file included from <<< inputs >>>:1:\ninput_line_2:1:9: error: use "
1535+
"of undeclared identifier 'x'\n 1 | int y = x;\n | "
1536+
"^\nFailed to parse via ::process:Parsing failed.\n");
1537+
testing::internal::CaptureStderr();
15301538
Cpp::Process("int x = 10;");
15311539
cerrs = testing::internal::GetCapturedStderr();
15321540
EXPECT_STREQ(cerrs.c_str(), "");
1541+
testing::internal::CaptureStderr();
1542+
Cpp::Process("int y = 10;");
1543+
cerrs = testing::internal::GetCapturedStderr();
1544+
EXPECT_STREQ(cerrs.c_str(), "");
1545+
Cpp::Undo(2);
1546+
testing::internal::CaptureStderr();
1547+
Cpp::Process("int x = 20;");
1548+
cerrs = testing::internal::GetCapturedStderr();
1549+
EXPECT_STREQ(cerrs.c_str(), "");
1550+
testing::internal::CaptureStderr();
1551+
Cpp::Process("int y = 20;");
1552+
cerrs = testing::internal::GetCapturedStderr();
1553+
EXPECT_STREQ(cerrs.c_str(), "");
15331554
}

0 commit comments

Comments
 (0)