Skip to content

Commit 7022a24

Browse files
committed
[ClangRepl] Fix failed ClangReplInterpreter unit tests (llvm#75556).
See more details: https://lab.llvm.org/buildbot/#/builders/119/builds/16346 Behalf of @vgvassilev
1 parent 4db0bd2 commit 7022a24

File tree

1 file changed

+33
-105
lines changed

1 file changed

+33
-105
lines changed

clang/unittests/Interpreter/CodeCompletionTest.cpp

Lines changed: 33 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,9 @@ static std::vector<std::string> runComp(clang::Interpreter &MainInterp,
5050
return Comps;
5151
}
5252

53-
#ifdef _AIX
54-
TEST(CodeCompletionTest, DISABLED_Sanity) {
55-
#else
5653
TEST(CodeCompletionTest, Sanity) {
57-
#endif
5854
auto Interp = createInterpreter();
59-
if (auto R = Interp->ParseAndExecute("int foo = 12;")) {
60-
consumeError(std::move(R));
61-
return;
62-
}
55+
cantFail(Interp->Parse("int foo = 12;"));
6356
auto Err = llvm::Error::success();
6457
auto comps = runComp(*Interp, "f", Err);
6558
EXPECT_EQ((size_t)2, comps.size()); // float and foo
@@ -68,36 +61,19 @@ TEST(CodeCompletionTest, Sanity) {
6861
EXPECT_EQ((bool)Err, false);
6962
}
7063

71-
#ifdef _AIX
72-
TEST(CodeCompletionTest, DISABLED_SanityNoneValid) {
73-
#else
7464
TEST(CodeCompletionTest, SanityNoneValid) {
75-
#endif
7665
auto Interp = createInterpreter();
77-
if (auto R = Interp->ParseAndExecute("int foo = 12;")) {
78-
consumeError(std::move(R));
79-
return;
80-
}
66+
cantFail(Interp->Parse("int foo = 12;"));
8167
auto Err = llvm::Error::success();
8268
auto comps = runComp(*Interp, "babanana", Err);
8369
EXPECT_EQ((size_t)0, comps.size()); // foo and float
8470
EXPECT_EQ((bool)Err, false);
8571
}
8672

87-
#ifdef _AIX
88-
TEST(CodeCompletionTest, DISABLED_TwoDecls) {
89-
#else
9073
TEST(CodeCompletionTest, TwoDecls) {
91-
#endif
9274
auto Interp = createInterpreter();
93-
if (auto R = Interp->ParseAndExecute("int application = 12;")) {
94-
consumeError(std::move(R));
95-
return;
96-
}
97-
if (auto R = Interp->ParseAndExecute("int apple = 12;")) {
98-
consumeError(std::move(R));
99-
return;
100-
}
75+
cantFail(Interp->Parse("int application = 12;"));
76+
cantFail(Interp->Parse("int apple = 12;"));
10177
auto Err = llvm::Error::success();
10278
auto comps = runComp(*Interp, "app", Err);
10379
EXPECT_EQ((size_t)2, comps.size());
@@ -113,29 +89,17 @@ TEST(CodeCompletionTest, CompFunDeclsNoError) {
11389

11490
TEST(CodeCompletionTest, TypedDirected) {
11591
auto Interp = createInterpreter();
116-
if (auto R = Interp->ParseAndExecute("int application = 12;")) {
117-
consumeError(std::move(R));
118-
return;
119-
}
120-
if (auto R = Interp->ParseAndExecute("char apple = '2';")) {
121-
consumeError(std::move(R));
122-
return;
123-
}
124-
if (auto R = Interp->ParseAndExecute("void add(int &SomeInt){}")) {
125-
consumeError(std::move(R));
126-
return;
127-
}
92+
cantFail(Interp->Parse("int application = 12;"));
93+
cantFail(Interp->Parse("char apple = '2';"));
94+
cantFail(Interp->Parse("void add(int &SomeInt){}"));
12895
{
12996
auto Err = llvm::Error::success();
13097
auto comps = runComp(*Interp, std::string("add("), Err);
13198
EXPECT_EQ((size_t)1, comps.size());
13299
EXPECT_EQ((bool)Err, false);
133100
}
134101

135-
if (auto R = Interp->ParseAndExecute("int banana = 42;")) {
136-
consumeError(std::move(R));
137-
return;
138-
}
102+
cantFail(Interp->Parse("int banana = 42;"));
139103

140104
{
141105
auto Err = llvm::Error::success();
@@ -157,22 +121,10 @@ TEST(CodeCompletionTest, TypedDirected) {
157121

158122
TEST(CodeCompletionTest, SanityClasses) {
159123
auto Interp = createInterpreter();
160-
if (auto R = Interp->ParseAndExecute("struct Apple{};")) {
161-
consumeError(std::move(R));
162-
return;
163-
}
164-
if (auto R = Interp->ParseAndExecute("void takeApple(Apple &a1){}")) {
165-
consumeError(std::move(R));
166-
return;
167-
}
168-
if (auto R = Interp->ParseAndExecute("Apple a1;")) {
169-
consumeError(std::move(R));
170-
return;
171-
}
172-
if (auto R = Interp->ParseAndExecute("void takeAppleCopy(Apple a1){}")) {
173-
consumeError(std::move(R));
174-
return;
175-
}
124+
cantFail(Interp->Parse("struct Apple{};"));
125+
cantFail(Interp->Parse("void takeApple(Apple &a1){}"));
126+
cantFail(Interp->Parse("Apple a1;"));
127+
cantFail(Interp->Parse("void takeAppleCopy(Apple a1){}"));
176128

177129
{
178130
auto Err = llvm::Error::success();
@@ -192,26 +144,11 @@ TEST(CodeCompletionTest, SanityClasses) {
192144

193145
TEST(CodeCompletionTest, SubClassing) {
194146
auto Interp = createInterpreter();
195-
if (auto R = Interp->ParseAndExecute("struct Fruit {};")) {
196-
consumeError(std::move(R));
197-
return;
198-
}
199-
if (auto R = Interp->ParseAndExecute("struct Apple : Fruit{};")) {
200-
consumeError(std::move(R));
201-
return;
202-
}
203-
if (auto R = Interp->ParseAndExecute("void takeFruit(Fruit &f){}")) {
204-
consumeError(std::move(R));
205-
return;
206-
}
207-
if (auto R = Interp->ParseAndExecute("Apple a1;")) {
208-
consumeError(std::move(R));
209-
return;
210-
}
211-
if (auto R = Interp->ParseAndExecute("Fruit f1;")) {
212-
consumeError(std::move(R));
213-
return;
214-
}
147+
cantFail(Interp->Parse("struct Fruit {};"));
148+
cantFail(Interp->Parse("struct Apple : Fruit{};"));
149+
cantFail(Interp->Parse("void takeFruit(Fruit &f){}"));
150+
cantFail(Interp->Parse("Apple a1;"));
151+
cantFail(Interp->Parse("Fruit f1;"));
215152
auto Err = llvm::Error::success();
216153
auto comps = runComp(*Interp, std::string("takeFruit("), Err);
217154
EXPECT_EQ((size_t)2, comps.size());
@@ -222,18 +159,9 @@ TEST(CodeCompletionTest, SubClassing) {
222159

223160
TEST(CodeCompletionTest, MultipleArguments) {
224161
auto Interp = createInterpreter();
225-
if (auto R = Interp->ParseAndExecute("int foo = 42;")) {
226-
consumeError(std::move(R));
227-
return;
228-
}
229-
if (auto R = Interp->ParseAndExecute("char fowl = 'A';")) {
230-
consumeError(std::move(R));
231-
return;
232-
}
233-
if (auto R = Interp->ParseAndExecute("void takeTwo(int &a, char b){}")) {
234-
consumeError(std::move(R));
235-
return;
236-
}
162+
cantFail(Interp->Parse("int foo = 42;"));
163+
cantFail(Interp->Parse("char fowl = 'A';"));
164+
cantFail(Interp->Parse("void takeTwo(int &a, char b){}"));
237165
auto Err = llvm::Error::success();
238166
auto comps = runComp(*Interp, std::string("takeTwo(foo, "), Err);
239167
EXPECT_EQ((size_t)1, comps.size());
@@ -243,9 +171,9 @@ TEST(CodeCompletionTest, MultipleArguments) {
243171

244172
TEST(CodeCompletionTest, Methods) {
245173
auto Interp = createInterpreter();
246-
cantFail(Interp->ParseAndExecute(
174+
cantFail(Interp->Parse(
247175
"struct Foo{int add(int a){return 42;} int par(int b){return 42;}};"));
248-
cantFail(Interp->ParseAndExecute("Foo f1;"));
176+
cantFail(Interp->Parse("Foo f1;"));
249177

250178
auto Err = llvm::Error::success();
251179
auto comps = runComp(*Interp, std::string("f1."), Err);
@@ -257,10 +185,10 @@ TEST(CodeCompletionTest, Methods) {
257185

258186
TEST(CodeCompletionTest, MethodsInvocations) {
259187
auto Interp = createInterpreter();
260-
cantFail(Interp->ParseAndExecute(
188+
cantFail(Interp->Parse(
261189
"struct Foo{int add(int a){return 42;} int par(int b){return 42;}};"));
262-
cantFail(Interp->ParseAndExecute("Foo f1;"));
263-
cantFail(Interp->ParseAndExecute("int a = 84;"));
190+
cantFail(Interp->Parse("Foo f1;"));
191+
cantFail(Interp->Parse("int a = 84;"));
264192

265193
auto Err = llvm::Error::success();
266194
auto comps = runComp(*Interp, std::string("f1.add("), Err);
@@ -271,11 +199,11 @@ TEST(CodeCompletionTest, MethodsInvocations) {
271199

272200
TEST(CodeCompletionTest, NestedInvocations) {
273201
auto Interp = createInterpreter();
274-
cantFail(Interp->ParseAndExecute(
202+
cantFail(Interp->Parse(
275203
"struct Foo{int add(int a){return 42;} int par(int b){return 42;}};"));
276-
cantFail(Interp->ParseAndExecute("Foo f1;"));
277-
cantFail(Interp->ParseAndExecute("int a = 84;"));
278-
cantFail(Interp->ParseAndExecute("int plus(int a, int b) { return a + b; }"));
204+
cantFail(Interp->Parse("Foo f1;"));
205+
cantFail(Interp->Parse("int a = 84;"));
206+
cantFail(Interp->Parse("int plus(int a, int b) { return a + b; }"));
279207

280208
auto Err = llvm::Error::success();
281209
auto comps = runComp(*Interp, std::string("plus(42, f1.add("), Err);
@@ -287,8 +215,8 @@ TEST(CodeCompletionTest, NestedInvocations) {
287215
TEST(CodeCompletionTest, TemplateFunctions) {
288216
auto Interp = createInterpreter();
289217
cantFail(
290-
Interp->ParseAndExecute("template <typename T> T id(T a) { return a;} "));
291-
cantFail(Interp->ParseAndExecute("int apple = 84;"));
218+
Interp->Parse("template <typename T> T id(T a) { return a;} "));
219+
cantFail(Interp->Parse("int apple = 84;"));
292220
{
293221
auto Err = llvm::Error::success();
294222
auto comps = runComp(*Interp, std::string("id<int>("), Err);
@@ -297,9 +225,9 @@ TEST(CodeCompletionTest, TemplateFunctions) {
297225
EXPECT_EQ((bool)Err, false);
298226
}
299227

300-
cantFail(Interp->ParseAndExecute(
228+
cantFail(Interp->Parse(
301229
"template <typename T> T pickFirst(T a, T b) { return a;} "));
302-
cantFail(Interp->ParseAndExecute("char pear = '4';"));
230+
cantFail(Interp->Parse("char pear = '4';"));
303231
{
304232
auto Err = llvm::Error::success();
305233
auto comps = runComp(*Interp, std::string("pickFirst(apple, "), Err);

0 commit comments

Comments
 (0)