Skip to content

Commit deec146

Browse files
committed
[move-function] Remove some unintended fr v and use more idiomatic self.assertXXX methods.
Thanks to @kastiglione for the suggestions on the more idiomatic method usage!
1 parent b5b9585 commit deec146

File tree

1 file changed

+19
-21
lines changed

1 file changed

+19
-21
lines changed

lldb/test/API/lang/swift/variables/move_function/TestSwiftMoveFunction.py

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def test_swift_move_function(self):
4545
self.process = self.target.LaunchSimple(None, None, os.getcwd())
4646
threads = lldbutil.get_threads_stopped_at_breakpoint(
4747
self.process, self.breakpoints[0])
48-
self.assertTrue(len(threads) == 1)
48+
self.assertEqual(len(threads), 1)
4949
self.thread = threads[0]
5050

5151
self.do_check_copyable_value_test()
@@ -68,7 +68,7 @@ def add_breakpoints(self, name, num_breakpoints):
6868
pat = pattern.format(name, i+1)
6969
brk = self.target.BreakpointCreateBySourceRegex(
7070
pat, self.main_source_spec)
71-
self.assertTrue(brk.GetNumLocations() > 0, VALID_BREAKPOINT)
71+
self.assertGreater(brk.GetNumLocations(), 0, VALID_BREAKPOINT)
7272
yield brk
7373

7474
def do_setup_breakpoints(self):
@@ -96,15 +96,15 @@ def do_check_copyable_value_test(self):
9696
# We haven't defined varK yet.
9797
varK = frame.FindVariable('k')
9898

99-
self.assertTrue(varK.value == None, "varK initialized too early?!")
99+
self.assertIsNone(varK.value, "varK initialized too early?!")
100100

101101
# Go to break point 2. k should be valid.
102102
self.runCmd('continue')
103-
self.assertTrue(varK.unsigned > 0, "varK not initialized?!")
103+
self.assertGreater(varK.unsigned, 0, "varK not initialized?!")
104104

105105
# Go to breakpoint 3. k should no longer be valid.
106106
self.runCmd('continue')
107-
self.assertTrue(varK.value == None, "K is live but was moved?!")
107+
self.assertIsNone(varK.value, "K is live but was moved?!")
108108

109109
# Run so we hit the next breakpoint to jump to the next test's
110110
# breakpoint.
@@ -116,20 +116,20 @@ def do_check_copyable_var_test(self):
116116

117117
# We haven't defined varK yet.
118118
varK = frame.FindVariable('k')
119-
self.assertTrue(varK.value == None, "varK initialized too early?!")
119+
self.assertIsNone(varK.value, "varK initialized too early?!")
120120

121121
# Go to break point 2. k should be valid.
122122
self.runCmd('continue')
123-
self.assertTrue(varK.unsigned > 0, "varK not initialized?!")
123+
self.assertGreater(varK.unsigned, 0, "varK not initialized?!")
124124

125125
# Go to breakpoint 3. We invalidated k
126126
self.runCmd('continue')
127-
self.assertTrue(varK.value == None, "K is live but was moved?!")
127+
self.assertIsNone(varK.value, "K is live but was moved?!")
128128

129129
# Go to the last breakpoint and make sure that k is reinitialized
130130
# properly.
131131
self.runCmd('continue')
132-
self.assertTrue(varK.unsigned > 0, "varK not initialized")
132+
self.assertGreater(varK.unsigned, 0, "varK not initialized")
133133

134134
# Run so we hit the next breakpoint to go to the next test.
135135
self.runCmd('continue')
@@ -147,12 +147,11 @@ def do_check_addressonly_value_test(self):
147147
# move the other variable and show the correct behavior with
148148
# llvm.dbg.declare.
149149
self.runCmd('continue')
150-
151-
self.assertTrue(varK.unsigned > 0, "var not initialized?!")
150+
self.assertGreater(varK.unsigned, 0, "var not initialized?!")
152151

153152
# Go to breakpoint 3.
154153
self.runCmd('continue')
155-
self.assertTrue(varK.unsigned == 0,
154+
self.assertEqual(varK.unsigned, 0,
156155
"dbg thinks varK is live despite move?!")
157156

158157
# Run so we hit the next breakpoint as part of the next test.
@@ -166,16 +165,16 @@ def do_check_addressonly_var_test(self):
166165

167166
# Go to break point 2. k should be valid.
168167
self.runCmd('continue')
169-
self.assertTrue(varK.unsigned > 0, "varK not initialized?!")
168+
self.assertGreater(varK.unsigned, 0, "varK not initialized?!")
170169

171170
# Go to breakpoint 3. K was invalidated.
172171
self.runCmd('continue')
173-
self.assertTrue(varK.value == None, "K is live but was moved?!")
172+
self.assertIsNone(varK.value, "K is live but was moved?!")
174173

175174
# Go to the last breakpoint and make sure that k is reinitialized
176175
# properly.
177176
self.runCmd('continue')
178-
self.assertTrue(varK.unsigned > 0, "varK not initialized")
177+
self.assertGreater(varK.unsigned, 0, "varK not initialized")
179178

180179
# Run so we hit the next breakpoint as part of the next test.
181180
self.runCmd('continue')
@@ -187,27 +186,26 @@ def do_check_copyable_value_ccf_true(self):
187186

188187
# Check at our start point that we do not have any state for varK and
189188
# then continue to our next breakpoint.
190-
self.assertTrue(varK.value == None, "varK should not have a value?!")
189+
self.assertIsNone(varK.value, "varK should not have a value?!")
191190
self.runCmd('continue')
192191

193192
# At this breakpoint, k should be defined since we are going to do
194193
# something with it.
195-
self.assertTrue(varK.value != None, "varK should have a value?!")
194+
self.assertIsNotNone(varK.value, "varK should have a value?!")
196195
self.runCmd('continue')
197196

198197
# At this breakpoint, we are now in the conditional control flow part of
199198
# the loop. Make sure that we can see k still.
200-
self.assertTrue(varK.value != None, "varK should have a value?!")
199+
self.assertIsNotNone(varK.value, "varK should have a value?!")
201200
self.runCmd('continue')
202201

203202
# Ok, we just performed the move. k should not be no longer initialized.
204-
self.runCmd('fr v')
205-
self.assertTrue(varK.value == None, "varK should not have a value?!")
203+
self.assertIsNone(varK.value, "varK should not have a value?!")
206204
self.runCmd('continue')
207205

208206
# Finally we left the conditional control flow part of the function. k
209207
# should still be None.
210-
self.assertTrue(varK.value == None, "varK should not have a value!")
208+
self.assertIsNone(varK.value, "varK should not have a value!")
211209

212210
def do_check_copyable_value_ccf_false(self):
213211
pass

0 commit comments

Comments
 (0)