Commits

tomo cocoa  committed 75b45a2

fixed bugs

  • Participants
  • Parent commits 959d56e

Comments (0)

Files changed (2)

         self.value = value
 
     def __str__(self):
-        return '{{{0}}}'.format(', '.join(self.value))
+        return '{{{0}}}'.format(self.value)
 
     def __repr__(self):
         return '<ring.BooleanAlgebra value: {0}>' \
 
     def __mul__(self, other):
         if type(self) == type(other):
-            retrun BooleanAlgebra(self.value & other.value)
+            return BooleanAlgebra(self.value & other.value)
         else:
             return other.__radd__(self)
 
     def __neg__(self):
-        return BooleanAlgebra(lp.Not(self))
+        return self
+
+BooleanAlgebra.ZERO = BooleanAlgebra()
+BooleanAlgebra.ONE = BooleanAlgebra(lp.T)

File tests/test_ring.py

 
 import pytest
 import ring
+import logics.prop as lp
 import tests.test_base
 import tests.test_group
 
 pytest_generate_tests = tests.test_base.pytest_generate_tests
 
-rings = [ring.Integer]
+rings = [ring.Integer, ring.BooleanAlgebra]
 
 integer_values = [ring.Integer(i) for i in range(-2, 3)]
 
+p = lp.Var('p')
+q = lp.Var('q')
+r = lp.Var('r')
+ba_values = [ring.BooleanAlgebra(v)
+             for v in [p, q, r, ~p, ~q, p & q, q | r, p ^ r]]
+
 single_params = [{'a': a} for a
-                 in integer_values]
+                 in integer_values +
+                 ba_values]
 
 double_params = [{'a': a, 'b': b}
                  for a in integer_values
-                 for b in integer_values]
+                 for b in integer_values] + \
+                [{'a': a, 'b': b}
+                 for a in ba_values
+                 for b in ba_values]
 
 triple_params = [{'a': a, 'b': b, 'c': c}
                  for a in integer_values
                  for b in integer_values
-                 for c in integer_values
-                 ]
+                 for c in integer_values] + \
+                [{'a': a, 'b': b, 'c': c}
+                 for a in ba_values
+                 for b in ba_values
+                 for c in ba_values]
 
 class TestEquality(tests.test_group.TestEquality):
     params = {