Exemple #1
0
 def test_xor(self):
     ctx = Backward()
     ans = ctx.read("a ^ b")
     self.assertEqual(str(ans), "[xor((atom(a), atom(b)))]")
     ans = ctx.read("!a ^ b")
     self.assertEqual(str(ans), "[xor((not(atom(a)), atom(b)))]")
     ans = ctx.read("a ^ !b")
     self.assertEqual(str(ans), "[xor((atom(a), not(atom(b))))]")
     ans = ctx.read("a ^ b | c")
     self.assertEqual(str(ans), "[or((xor((atom(a), atom(b))), atom(c)))]")
Exemple #2
0
 def test_or(self):
     ctx = Backward()
     ans = ctx.read("a | b")
     self.assertEqual(str(ans), "[or((atom(a), atom(b)))]")
     ans = ctx.read("!a | b")
     self.assertEqual(str(ans), "[or((not(atom(a)), atom(b)))]")
     ans = ctx.read("a | !b")
     self.assertEqual(str(ans), "[or((atom(a), not(atom(b))))]")
     ans = ctx.read("a | b & c")
     self.assertEqual(str(ans), "[and((or((atom(a), atom(b))), atom(c)))]")
Exemple #3
0
 def test_empty(self):
     ctx = Backward()
     ans = ctx.read("")
     self.assertEqual(str(ans), "[]")
Exemple #4
0
 def test_not(self):
     ctx = Backward()
     ans = ctx.read("!a")
     self.assertEqual(str(ans), "[not(atom(a))]")
     ans = ctx.read("!a !b")
     self.assertEqual(str(ans), "[not(atom(a)), not(atom(b))]")
Exemple #5
0
 def test_atom(self):
     ctx = Backward()
     ans = ctx.read("a")
     self.assertEqual(str(ans), "[atom(a)]")
     ans = ctx.read("a b c")
     self.assertEqual(str(ans), "[atom(a), atom(b), atom(c)]")