Attention une mise à jour du service Gitlab va être effectuée le mardi 18 janvier (et non lundi 17 comme annoncé précédemment) entre 18h00 et 18h30. Cette mise à jour va générer une interruption du service dont nous ne maîtrisons pas complètement la durée mais qui ne devrait pas excéder quelques minutes.

Commit beafe977 authored by VIGNET Pierre's avatar VIGNET Pierre
Browse files

[lib] Logic expressions: Update tests

parent a1d7c084
......@@ -138,56 +138,71 @@ class TestExpressionAnalyzer(unittest.TestCase):
test expression equality (necessary for tests!!)
"""
# ident
res = self.exp1.test_equal(self.exp1)
res = self.exp1 == self.exp1
self.assert_(res, "Error in Expression equality Test01")
res = self.exp1.test_equal(self.exp2)
res = self.exp1 == self.exp2
self.assert_(not res, "Error in Expression equality Test02")
# default
exp10 = SigDefaultExpr(self.exp1, self.exp2) # X1 default X2
exp101 = SigDefaultExpr(exp10, self.exp3) #( X1 default X2) default X3
res = exp101.test_equal(exp101)
res = exp101 == exp101
self.assert_(res, "Error in Expression equality Test1")
# when
exp11 = SigWhenExpr(self.exp3, self.exp4) # X3 when X4
exp111 = SigWhenExpr(exp11, self.exp2) # (X3 when X4) when X2
res = exp111.test_equal(exp111)
res = exp111 == exp111
self.assert_(res, "Error in Expression equality Test2")
res = exp111.test_equal(exp101)
res = exp111 == exp101
self.assert_(not res, "Error in Expression equality Test3")
# when and default
exp112 = SigDefaultExpr(self.exp1, exp11) # X1 default (X3 when X4)
res = exp112.test_equal(exp112)
res = exp112 == exp112
self.assert_(res, "Error in Expression equality Test4")
res = exp112.test_equal(exp101)
res = exp112 == exp101
self.assert_(not res, "Error in Expression equality Test5")
# binary bool exp
exp12 = SigSyncBinExpr('or', self.exp1, self.exp2)
exp121 = SigWhenExpr(self.exp3, exp12)
res = exp121.test_equal(exp121)
res = exp121 == exp121
self.assert_(res, "Error in Expression equality Test6")
exp13 = SigSyncBinExpr('and', self.exp1, self.exp2)
exp131 = SigWhenExpr(self.exp3, exp13)
res = exp131.test_equal(exp131)
res = exp131 == exp131
self.assert_(res, "Error in Expression equality Test7")
res = exp121.test_equal(exp131)
res = exp121 == exp131
self.assert_(not res, "Error in Expression equality Test8")
# binary bool exp whith constants
exp14 = SigSyncBinExpr('or', self.exp1, SigConstExpr(True))
exp141 = SigSyncBinExpr('or', self.exp1, SigConstExpr(False))
res = exp141.test_equal(exp141)
res = exp141 == exp141
self.assert_(res, "Error in Expression equality Test9")
res = exp141.test_equal(exp14)
res = exp141 == exp14
self.assert_(not res, "Error in Expression equality Test10")
print(self.err_rep.message)
self.assert_(not self.err_rep.error, "reporter captured an error")
# Check unicity of expressions
expressions = set([exp10, exp101, exp11, exp111, exp112, exp12, exp121, exp13, exp131, exp14, exp141])
print(expressions, len(expressions))
assert len(expressions) == 11
expressions.update([
SigDefaultExpr(exp10, self.exp3), # 101
SigWhenExpr(exp11, self.exp2), # 111
SigDefaultExpr(self.exp1, exp11), # 112
SigWhenExpr(self.exp3, exp12), # 121
SigWhenExpr(self.exp3, exp13), # 131
SigSyncBinExpr('or', self.exp1, SigConstExpr(False)), # 141
])
print(expressions, len(expressions))
assert len(expressions) == 11
def test_default(self):
"""
......@@ -206,7 +221,7 @@ class TestExpressionAnalyzer(unittest.TestCase):
exp10 = SigDefaultExpr(self.exp1, self.exp2) # X1 default X2
exp101 = SigDefaultExpr(exp10, self.exp3) #( X1 default X2) default X3
res = exp101.test_equal(exp_obj.exp)
res = exp101 == exp_obj.exp
self.assert_(res, "Error in Expression analyzer for default")
print(self.err_rep.message)
......@@ -227,7 +242,7 @@ class TestExpressionAnalyzer(unittest.TestCase):
self.assert_(False, "Compiler error for when")
exp11 = SigWhenExpr(self.exp3, self.exp4) # X3 when X4
exp111 = SigWhenExpr(exp11, self.exp2) # (X3 when X4) when X2
res = exp111.test_equal(exp_obj.exp)
res = exp111 == exp_obj.exp
self.assert_(res, "Error in Expression analyzer for when")
print(self.err_rep.message)
......@@ -248,7 +263,7 @@ class TestExpressionAnalyzer(unittest.TestCase):
self.assert_(False, "Compiler error for default_when")
exp11 = SigWhenExpr(self.exp3, self.exp4) # X3 when X4
exp112 = SigDefaultExpr(self.exp1, exp11) # X1 default (X3 when X4)
res = exp112.test_equal(exp_obj.exp)
res = exp112 == exp_obj.exp
mess = "Error in Expression analyzer for X1 default X3 when X4"
self.assert_(res, mess)
......@@ -269,14 +284,14 @@ class TestExpressionAnalyzer(unittest.TestCase):
parser.displayExceptionMessage(exc)
self.assert_(False, "Compiler error for void")
expv = SigConstExpr(True)
res = expv.test_equal(exp_obj.exp)
res = expv == exp_obj.exp
mess = "Error in void expression - must default to True"
self.assert_(res, mess)
# exp11 = SigWhenExpr(self.exp3,self.exp4) # X3 when X4
# exp112 = SigDefaultExpr(self.exp1, exp11) # X1 default (X3 when X4)
# res = exp112.test_equal(exp_obj.exp)
# res = exp112 == exp_obj.exp
# mess = "Error in Expression analyzer for (X1 and X3 and X4)"
# self.assert_(res, mess)
print(self.err_rep.message)
......@@ -297,7 +312,7 @@ class TestExpressionAnalyzer(unittest.TestCase):
self.assert_(False, "Compiler error for when")
exp11 = SigSyncBinExpr('or', self.exp4, self.exp2) # X4 or X2
exp111 = SigWhenExpr(self.exp3, exp11) # X3 when (X4 or X2)
res = exp111.test_equal(exp_obj.exp)
res = exp111 == exp_obj.exp
self.assert_(res, "Error in Expression analyzer for when_or")
print(self.err_rep.message)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment