提交 2fb9d9ab authored 作者: James Bergstra's avatar James Bergstra

added test of read-only constants in ModuleInstance

上级 036187eb
......@@ -184,7 +184,6 @@ class External(_RComponent):
rval += '\n= %s' % (pprint(self.r, dict(target = self.r)))
return rval
class Member(_RComponent):
"""
Member represents a Variable which is a state of a Composite. That
......
......@@ -506,6 +506,47 @@ class T_module(unittest.TestCase):
M = Module()
M.a = [1,2,3]
M.make()
m = M.make()
print m.a
print m.a[0], type(m.a[0]), m.a[0] == 1
print list(m.a)
assert list(m.a) == [1,2,3]
assert m.a is not M.a
try:
m.a = [4, 5, 6]
assert False
except Exception, e:
if e[0].startswith("Cannot set readonly"):
pass
else:
raise
try:
m.a[0] = 4
assert False
except Exception, e:
if e[0].startswith("Cannot set readonly"):
pass
else:
raise
def test_mixed_list(self):
M = Module()
M.a = [1,2,T.lscalar()]
m = M.make()
assert list(m.a) == [1,2,None]
assert m.a is not M.a
try:
m.a[0] = 4
assert False
except Exception, e:
if e[0].startswith("Cannot set readonly"):
pass
else:
raise
m.a[2] = 3
assert list(m.a) == [1,2,3]
def test_multiple_references():
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论