assert other.bits == self.bits
other = other.value
if isinstance(other, int):
- return other >= self.value
+ return onebit(self.value >= other.value)
assert False
def __le__(self, other):
assert other.bits == self.bits
other = other.value
if isinstance(other, int):
- return onebit(other <= self.value)
+ return onebit(self.value <= other)
assert False
def __gt__(self, other):
assert other.bits == self.bits
other = other.value
if isinstance(other, int):
- return onebit(other > self.value)
+ return onebit(self.value > other)
assert False
def __lt__(self, other):
assert other.bits == self.bits
other = other.value
if isinstance(other, int):
- return onebit(other < self.value)
+ return onebit(self.value < other)
assert False
def __eq__(self, other):
b = eval(repr(a))
self.assertEqual(a, b)
+ def test_cmp(self):
+ a = SelectableInt(10, bits=8)
+ b = SelectableInt(5, bits=8)
+ self.assertTrue(a > b)
+ self.assertFalse(a < b)
+ self.assertTrue(a != b)
+ self.assertFalse(a == b)
+
+ def test_unsigned(self):
+ a = SelectableInt(0x80, bits=8)
+ b = SelectableInt(0x7f, bits=8)
+ self.assertTrue(a > b)
+ self.assertFalse(a < b)
+ self.assertTrue(a != b)
+ self.assertFalse(a == b)
+
if __name__ == "__main__":
unittest.main()