mirror of
https://github.com/myhdl/myhdl.git
synced 2025-01-24 21:52:56 +08:00
corrected slice assign test
This commit is contained in:
parent
693ed3f180
commit
f7d707e4ad
@ -51,7 +51,6 @@ class intbv(object):
|
|||||||
else:
|
else:
|
||||||
raise TypeError("intbv constructor arg should be int or string")
|
raise TypeError("intbv constructor arg should be int or string")
|
||||||
self._checkBounds()
|
self._checkBounds()
|
||||||
|
|
||||||
|
|
||||||
def _checkBounds(self):
|
def _checkBounds(self):
|
||||||
if self._max is not None:
|
if self._max is not None:
|
||||||
@ -62,7 +61,6 @@ class intbv(object):
|
|||||||
if self._val < self._min:
|
if self._val < self._min:
|
||||||
raise ValueError("intbv value %s < minimum %s" %
|
raise ValueError("intbv value %s < minimum %s" %
|
||||||
(self._val, self._min))
|
(self._val, self._min))
|
||||||
|
|
||||||
|
|
||||||
# concat method
|
# concat method
|
||||||
def concat(self, *args):
|
def concat(self, *args):
|
||||||
|
@ -56,26 +56,26 @@ class TestIntbvBounds(TestCase):
|
|||||||
def testSliceAssign(self):
|
def testSliceAssign(self):
|
||||||
a = intbv(min=-24, max=34)
|
a = intbv(min=-24, max=34)
|
||||||
for i in (-24, -2, 13, 33):
|
for i in (-24, -2, 13, 33):
|
||||||
a[:] = i
|
for k in (0, 9, 10):
|
||||||
a[10:] = i
|
a[k:] = i
|
||||||
for i in (-25, -128, 34, 35, 229):
|
for i in (-25, -128, 34, 35, 229):
|
||||||
|
for k in (0, 9, 10):
|
||||||
|
try:
|
||||||
|
a[k:] = i
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
self.fail()
|
||||||
|
a = intbv(5)[8:]
|
||||||
|
for v in (0, 2**8-1, 100):
|
||||||
|
a[:] = v
|
||||||
|
for v in (-1, 2**8, -10, 1000):
|
||||||
try:
|
try:
|
||||||
a[:] = i
|
a[:] = v
|
||||||
a[10:] = i
|
|
||||||
except ValueError:
|
except ValueError:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
self.fail()
|
self.fail()
|
||||||
a = intbv(5)[8:]
|
|
||||||
a[:] = 0
|
|
||||||
a[:] = 2**8-1
|
|
||||||
try:
|
|
||||||
a[:] = -1
|
|
||||||
a[:] = 2**8
|
|
||||||
except ValueError:
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
self.fail()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user