[lldb][test] Modernize assertEqual(value, bool) (#82526)

Any time we see the pattern `assertEqual(value, bool)`, we can replace
that with `assert<bool>(value)`. Likewise for `assertNotEqual`.

Technically this relaxes the test a bit, as we may want to make sure
`value` is either `True` or `False`, and not something that implicitly
converts to a bool. For example, `assertEqual("foo", True)` will fail,
but `assertTrue("foo")` will not. In most cases, this distinction is not
important.

There are two such places that this patch does **not** transform, since
it seems intentional that we want the result to be a bool:
*
5daf2001a1/lldb/test/API/python_api/sbstructureddata/TestStructuredDataAPI.py (L90)
*
5daf2001a1/lldb/test/API/commands/settings/TestSettings.py (L940)

Followup to 9c2468821e. I patched `teyit`
with a `visit_assertEqual` node handler to generate this.
This commit is contained in:
Jordan Rupprecht
2024-02-21 20:39:02 -06:00
committed by GitHub
parent 0d12628d06
commit 1eeeab82c6
19 changed files with 95 additions and 114 deletions

View File

@@ -79,13 +79,13 @@ class SBCommandInterpreterRunOptionsCase(TestBase):
opts = lldb.SBCommandInterpreterRunOptions()
# Check getters with default values
self.assertEqual(opts.GetStopOnContinue(), False)
self.assertEqual(opts.GetStopOnError(), False)
self.assertEqual(opts.GetStopOnCrash(), False)
self.assertEqual(opts.GetEchoCommands(), True)
self.assertEqual(opts.GetPrintResults(), True)
self.assertEqual(opts.GetPrintErrors(), True)
self.assertEqual(opts.GetAddToHistory(), True)
self.assertFalse(opts.GetStopOnContinue())
self.assertFalse(opts.GetStopOnError())
self.assertFalse(opts.GetStopOnCrash())
self.assertTrue(opts.GetEchoCommands())
self.assertTrue(opts.GetPrintResults())
self.assertTrue(opts.GetPrintErrors())
self.assertTrue(opts.GetAddToHistory())
# Invert values
opts.SetStopOnContinue(not opts.GetStopOnContinue())
@@ -97,10 +97,10 @@ class SBCommandInterpreterRunOptionsCase(TestBase):
opts.SetAddToHistory(not opts.GetAddToHistory())
# Check the value changed
self.assertEqual(opts.GetStopOnContinue(), True)
self.assertEqual(opts.GetStopOnError(), True)
self.assertEqual(opts.GetStopOnCrash(), True)
self.assertEqual(opts.GetEchoCommands(), False)
self.assertEqual(opts.GetPrintResults(), False)
self.assertEqual(opts.GetPrintErrors(), False)
self.assertEqual(opts.GetAddToHistory(), False)
self.assertTrue(opts.GetStopOnContinue())
self.assertTrue(opts.GetStopOnError())
self.assertTrue(opts.GetStopOnCrash())
self.assertFalse(opts.GetEchoCommands())
self.assertFalse(opts.GetPrintResults())
self.assertFalse(opts.GetPrintErrors())
self.assertFalse(opts.GetAddToHistory())