提交 cabe6a9e authored 作者: Frederic Bastien's avatar Frederic Bastien

added implementation of test_shared_members. This found a bug that list of list,…

added implementation of test_shared_members. This found a bug that list of list, list of tuple, tuple of list of member don't work
上级 8774bdef
...@@ -144,7 +144,64 @@ class T_test_module(unittest.TestCase): ...@@ -144,7 +144,64 @@ class T_test_module(unittest.TestCase):
def test_shared_members(self): def test_shared_members(self):
"""Test that under a variety of tricky conditions, the shared-ness of Results and Members """Test that under a variety of tricky conditions, the shared-ness of Results and Members
is respected.""" is respected."""
print >> sys.stderr, "WARNING MODULE TEST NOT IMPLEMENTED"
m1=Module()
m2=Module()
x=T.dscalar()
m1.x=Member(x)
m2.x=Member(x)
m1.lx=[Member(x)]
m2.lx=[Member(x)]
m1.llx=[[Member(x)],[Member(x)]]
m2.llx=[[Member(x)],[Member(x)]]
m1.ltx=[(Member(x),)]
m2.ltx=[(Member(x),)]
m1.tx=(Member(x),)
m2.tx=(Member(x),)
m1.tlx=([Member(x)],)
m2.tlx=([Member(x)],)
#m1.x and m2.x should not be shared as their is no hierarchi link between them.
inst1=m1.make()
inst2=m2.make()
inst1.x=1
inst2.x=2
assert inst1.x==1
assert inst2.x==2
assert inst1.lx[0]==1
assert inst2.lx[0]==2
assert inst1.ltx[0][0]==1#BUG: list of tuple don't work
assert inst2.ltx[0][0]==2#BUG: list of tuple don't work
assert inst1.llx[0][0]==1#BUG: list of list don't work
assert inst2.llx[0][0]==2#BUG: list of list don't work
assert inst1.llx[1][0]==1#BUG: list of list don't work
assert inst2.llx[1][0]==2#BUG: list of list don't work
assert inst1.tx[0]==1
assert inst2.tx[0]==2
assert inst1.tlx[0][0]==1#BUG: tuple of list don't work
assert inst2.tlx[0][0]==2#BUG: tuple of list don't work
#m1.x and m2.x should be shared as their is a hierarchi link between them.
m1.m2=m2
inst=m1.make()
inst.x=1
assert inst.x==1
assert inst.m2.x==1
assert inst.lx[0]==1
assert inst.m2.lx[0]==1
assert inst.tx[0]==1
assert inst.m2.tx[0]==1
inst.m2.x=2
assert inst.x==2
assert inst.m2.x==2
assert inst.lx[0]==2
assert inst.m2.lx[0]==2
assert inst.tx[0]==2
assert inst.m2.tx[0]==2
#same preceding test with list, tuple and dict
print >> sys.stderr, "WARNING MODULE TEST NOT IMPLEMENTED4"
#put them in subModules, sub-sub-Modules, shared between a list and a dict, shared between #put them in subModules, sub-sub-Modules, shared between a list and a dict, shared between
#a list and a submodule with a dictionary, etc... #a list and a submodule with a dictionary, etc...
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论