Skip to content

Commit 42b9a68

Browse files
committed
[lldb][NFC] Use expect_expr in more tests
1 parent 1d2ede8 commit 42b9a68

File tree

7 files changed

+32
-39
lines changed

7 files changed

+32
-39
lines changed

lldb/test/API/commands/expression/argument_passing_restrictions/TestArgumentPassingRestrictions.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ def test_argument_passing_restrictions(self):
2626
lldbutil.run_to_source_breakpoint(self, '// break here',
2727
lldb.SBFileSpec("main.cpp"))
2828

29-
self.expect("expr returnPassByRef()",
30-
substrs=['(PassByRef)', '= 11223344'])
29+
self.expect_expr("returnPassByRef()", result_type="PassByRef", result_children=[
30+
ValueCheck(name="x", value="11223344")
31+
])
3132

32-
self.expect("expr takePassByRef(p)",
33-
substrs=['(int)', '= 42'])
33+
self.expect_expr("takePassByRef(p)", result_type="int", result_value="42")

lldb/test/API/commands/expression/cast_int_to_anonymous_enum/TestCastIntToAnonymousEnum.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ def test_cast_int_to_anonymous_enum(self):
1919
lldbutil.run_to_source_breakpoint(self, '// break here',
2020
lldb.SBFileSpec("main.cpp", False))
2121

22-
self.expect("expr (flow_e)0", substrs=['(flow_e) $0 = A'])
22+
self.expect_expr("(flow_e)0", result_type="flow_e", result_value="A")

lldb/test/API/commands/expression/expr-in-syscall/TestExpressionInSyscall.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,8 @@ def expr_syscall(self):
7474
thread = process.GetSelectedThread()
7575

7676
# try evaluating a couple of expressions in this state
77-
self.expect("expr release_flag = 1", substrs=[" = 1"])
78-
self.expect("print (int)getpid()",
79-
substrs=[str(process.GetProcessID())])
77+
self.expect_expr("release_flag = 1", result_value="1")
78+
self.expect_expr("(int)getpid()", result_value=str(process.GetProcessID()))
8079

8180
# and run the process to completion
8281
process.Continue()

lldb/test/API/commands/expression/function_template_specialization_temp_args/TestFunctionTemplateSpecializationTempArgs.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,4 @@ def test_function_template_specialization_temp_args(self):
1313
(self.target, self.process, _, bkpt) = lldbutil.run_to_source_breakpoint(self, '// break here',
1414
lldb.SBFileSpec("main.cpp", False))
1515

16-
self.expect("expr p0",
17-
substrs=['(VType) $0 = {}'])
16+
self.expect_expr("p0", result_type="VType", result_children=[])

lldb/test/API/commands/expression/ignore-artificial-constructors/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ struct Foo {
66
int main() {
77
Foo f;
88
// Try to construct foo in our expression.
9-
return 0; //%self.expect("expr Foo()", substrs=["(Foo) $0 = {}"])
9+
return 0; //%self.expect_expr("Foo()", result_type="Foo", result_children=[])
1010
}

lldb/test/API/lang/cpp/namespace/TestNamespace.py

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,11 @@ def test_with_run_command(self):
152152

153153
self.runToBkpt("run")
154154
# Evaluate ns1::value
155-
self.expect("expression -- value", startstr="(int) $0 = 100")
155+
self.expect_expr("value", result_value="100")
156156

157157
self.runToBkpt("continue")
158158
# Evaluate ns2::value
159-
self.expect("expression -- value", startstr="(int) $1 = 200")
159+
self.expect_expr("value", result_value="200")
160160

161161
self.runToBkpt("continue")
162162
# On Mac OS X, gcc 4.2 emits the wrong debug info with respect to
@@ -206,28 +206,23 @@ def test_with_run_command(self):
206206
# rdar://problem/8660275
207207
# test/namespace: 'expression -- i+j' not working
208208
# This has been fixed.
209-
self.expect("expression -- i + j",
210-
startstr="(int) $2 = 7")
209+
self.expect_expr("i + j", result_type="int", result_value="7")
211210
# (int) $2 = 7
212211

213-
self.runCmd("expression -- i")
214-
self.runCmd("expression -- j")
212+
self.expect_expr("i", result_value="3")
213+
self.expect_expr("j", result_value="4")
215214

216215
# rdar://problem/8668674
217216
# expression command with fully qualified namespace for a variable does
218217
# not work
219-
self.expect("expression -- ::i", VARIABLES_DISPLAYED_CORRECTLY,
220-
patterns=[' = 3'])
221-
self.expect("expression -- A::B::j", VARIABLES_DISPLAYED_CORRECTLY,
222-
patterns=[' = 4'])
218+
self.expect_expr("::i", result_value="3")
219+
self.expect_expr("A::B::j", result_value="4")
223220

224221
# expression command with function in anonymous namespace
225-
self.expect("expression -- myanonfunc(3)",
226-
patterns=[' = 6'])
222+
self.expect_expr("myanonfunc(3)", result_value="6")
227223

228224
# global namespace qualification with function in anonymous namespace
229-
self.expect("expression -- ::myanonfunc(4)",
230-
patterns=[' = 8'])
225+
self.expect_expr("myanonfunc(4)", result_value="8")
231226

232227
self.expect("p myanonfunc",
233228
patterns=['\(anonymous namespace\)::myanonfunc\(int\)'])

lldb/test/API/lang/objc/objc_direct-methods/main.m

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ @implementation Foo
1818
-(int) entryPoint
1919
{
2020
// Try calling directly with self. Same as in the main method otherwise.
21-
return 0; //%self.expect("expr [self directCallNoArgs]", substrs=["called directCallNoArgs"])
22-
//%self.expect("expr [self directCallArgs: 1111]", substrs=["= 2345"])
23-
//%self.expect("expr side_effect = 0; [self directCallVoidReturn]; side_effect", substrs=["= 4321"])
24-
//%self.expect("expr [self directCallNSStringArg: str]", substrs=['@"some string"'])
25-
//%self.expect("expr [self directCallIdArg: (id)str]", substrs=['@"some string appendix"'])
26-
//%self.expect("expr [self directCallConflictingName]", substrs=["correct function"])
27-
//%self.expect("expr [self directCallWithCategory]", substrs=["called function with category"])
21+
return 0; //%self.expect_expr("[self directCallNoArgs]", result_summary='"called directCallNoArgs"')
22+
//%self.expect_expr("[self directCallArgs: 1111]", result_value="2345")
23+
//%self.expect_expr("side_effect = 0; [self directCallVoidReturn]; side_effect", result_value="4321")
24+
//%self.expect_expr("[self directCallNSStringArg: str]", result_summary='@"some string"')
25+
//%self.expect_expr("[self directCallIdArg: (id)str]", result_summary='@"some string appendix"')
26+
//%self.expect_expr("[self directCallConflictingName]", result_summary='"correct function"')
27+
//%self.expect_expr("[self directCallWithCategory]", result_summary='"called function with category"')
2828
}
2929

3030
// Declare several objc_direct functions we can test.
@@ -81,12 +81,12 @@ int main()
8181
[foo directCallVoidReturn];
8282
[foo directCallNSStringArg: str];
8383
[foo directCallIdArg: (id)str];
84-
[foo entryPoint]; //%self.expect("expr [foo directCallNoArgs]", substrs=["called directCallNoArgs"])
85-
//%self.expect("expr [foo directCallArgs: 1111]", substrs=["= 2345"])
86-
//%self.expect("expr side_effect = 0; [foo directCallVoidReturn]; side_effect", substrs=["= 4321"])
87-
//%self.expect("expr [foo directCallNSStringArg: str]", substrs=['@"some string"'])
88-
//%self.expect("expr [foo directCallIdArg: (id)str]", substrs=['@"some string appendix"'])
89-
//%self.expect("expr [foo directCallConflictingName]", substrs=["correct function"])
90-
//%self.expect("expr [foo directCallWithCategory]", substrs=["called function with category"])
84+
[foo entryPoint]; //%self.expect_expr("[foo directCallNoArgs]", result_summary='"called directCallNoArgs"')
85+
//%self.expect_expr("[foo directCallArgs: 1111]", result_value="2345")
86+
//%self.expect_expr("side_effect = 0; [foo directCallVoidReturn]; side_effect", result_value="4321")
87+
//%self.expect_expr("[foo directCallNSStringArg: str]", result_summary='@"some string"')
88+
//%self.expect_expr("[foo directCallIdArg: (id)str]", result_summary='@"some string appendix"')
89+
//%self.expect_expr("[foo directCallConflictingName]", result_summary='"correct function"')
90+
//%self.expect_expr("[foo directCallWithCategory]", result_summary='"called function with category"')
9191
return 0;
9292
}

0 commit comments

Comments
 (0)