[Python] Implement truth testing for lldb.value

Python 3 calls __bool__() instead of __len__() and lldb.value only
implemented the __len__ method. This adds the __bool__() implementation.

Differential revision: https://reviews.llvm.org/D67183

llvm-svn: 370953
This commit is contained in:
Jonas Devlieghere 2019-09-04 18:59:10 +00:00
parent 5559406ae5
commit 24223eb24c
2 changed files with 7 additions and 0 deletions

View File

@ -160,6 +160,10 @@ class ValueAPITestCase(TestBase):
val_i.GetType()).AddressOf(),
VALID_VARIABLE)
# Check that lldb.value implements truth testing.
self.assertFalse(lldb.value(frame0.FindVariable('bogus')))
self.assertTrue(lldb.value(frame0.FindVariable('uinthex')))
self.assertTrue(int(lldb.value(frame0.FindVariable('uinthex')))
== 3768803088, 'uinthex == 3768803088')
self.assertTrue(int(lldb.value(frame0.FindVariable('sinthex')))

View File

@ -980,6 +980,9 @@ class value(object):
def __nonzero__(self):
return self.sbvalue.__nonzero__()
def __bool__(self):
return self.sbvalue.__bool__()
def __str__(self):
return self.sbvalue.__str__()