add abs SelectableInt unit test (very quick)
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 19 Jun 2020 14:27:25 +0000 (15:27 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 19 Jun 2020 14:27:25 +0000 (15:27 +0100)
src/soc/decoder/selectable_int.py

index eebada688102162877cd574cd395fa98c65467b7..8e0564f6cd210cc998302cd03cea5d7b6bd6f589 100644 (file)
@@ -412,6 +412,8 @@ class SelectableIntTestCase(unittest.TestCase):
         d = a - b
         e = a * b
         f = -a
+        g = abs(f)
+        h = abs(a)
         self.assertEqual(c.value, a.value + b.value)
         self.assertEqual(d.value, (a.value - b.value) & 0xFF)
         self.assertEqual(e.value, (a.value * b.value) & 0xFF)
@@ -419,6 +421,8 @@ class SelectableIntTestCase(unittest.TestCase):
         self.assertEqual(c.bits, a.bits)
         self.assertEqual(d.bits, a.bits)
         self.assertEqual(e.bits, a.bits)
+        self.assertEqual(a.bits, f.bits)
+        self.assertEqual(a.bits, h.bits)
 
     def test_logic(self):
         a = SelectableInt(0x0F, 8)