Ejemplo n.º 1
0
 def test_conflict_free_venice_framework(self):
     baba = ExampleFrameworks.venice_framework()
     self.assertTrue(Semantics.conflict_free(baba, [a]),
                     "Expected: conflict free")
     self.assertTrue(Semantics.conflict_free(baba, [b]),
                     "Expected: conflict free")
     self.assertTrue(Semantics.conflict_free(baba, [c]),
                     "Expected: conflict free")
     self.assertTrue(Semantics.conflict_free(baba, [d]),
                     "Expected: conflict free")
     self.assertTrue(Semantics.conflict_free(baba, [e]),
                     "Expected: conflict free")
     self.assertTrue(Semantics.conflict_free(baba, [a, c]),
                     "Expected: conflict free")
     self.assertTrue(Semantics.conflict_free(baba, [a, d]),
                     "Expected: conflict free")
     self.assertTrue(Semantics.conflict_free(baba, [a, e]),
                     "Expected: conflict free")
     self.assertTrue(Semantics.conflict_free(baba, [b, d]),
                     "Expected: conflict free")
     self.assertTrue(Semantics.conflict_free(baba, [b, e]),
                     "Expected: conflict free")
     self.assertTrue(Semantics.conflict_free(baba, [c, e]),
                     "Expected: conflict free")
     self.assertTrue(Semantics.conflict_free(baba, [a, c, e]),
                     "Expected: conflict free")
     self.assertFalse(Semantics.conflict_free(baba, [b, c]),
                      "Expected: NOT conflict free")
     self.assertFalse(Semantics.conflict_free(baba, [c, d]),
                      "Expected: NOT conflict free")
     self.assertFalse(Semantics.conflict_free(baba, [a, b, c]),
                      "Expected: NOT conflict free")
     self.assertFalse(Semantics.conflict_free(baba, [a, b, d]),
                      "Expected: NOT conflict free")
     self.assertFalse(Semantics.conflict_free(baba, [a, b, e]),
                      "Expected: NOT conflict free")
     self.assertFalse(Semantics.conflict_free(baba, [b, c, d]),
                      "Expected: NOT conflict free")
     self.assertFalse(Semantics.conflict_free(baba, [b, c, e]),
                      "Expected: NOT conflict free")
     self.assertFalse(Semantics.conflict_free(baba, [c, d, e]),
                      "Expected: NOT conflict free")
     self.assertFalse(Semantics.conflict_free(baba, [a, b, c, d]),
                      "Expected: NOT conflict free")
     self.assertFalse(Semantics.conflict_free(baba, [a, b, c, e]),
                      "Expected: NOT conflict free")
     self.assertFalse(Semantics.conflict_free(baba, [a, b, d, e]),
                      "Expected: NOT conflict free")
     self.assertFalse(Semantics.conflict_free(baba, [a, c, d, e]),
                      "Expected: NOT conflict free")
     self.assertFalse(Semantics.conflict_free(baba, [a, b, c, d, e]),
                      "Expected: NOT conflict free")
Ejemplo n.º 2
0
from PythonSemantics import ExampleFrameworks, Semantics

a = Semantics.Sentence('a')
b = Semantics.Sentence('b')
c = Semantics.Sentence('c')
d = Semantics.Sentence('d')
e = Semantics.Sentence('e')
f = Semantics.Sentence('f')
g = Semantics.Sentence('g')
h = Semantics.Sentence('h')
i = Semantics.Sentence('i')
j = Semantics.Sentence('j')

larger_baba = ExampleFrameworks.larger_framework()
venice_baba = ExampleFrameworks.venice_framework()
s_baba = ExampleFrameworks.s_framework()


class TestSemantics(unittest.TestCase):
    def test_rule_initialises_with_no_body(self):
        head = 0
        rule = Semantics.Rule(head)

        self.assertEqual(head, rule.head)
        self.assertEqual([], rule.body, [])

    def test_rule_initialises_with_body(self):
        head = 0
        body = [1, 2, 3]
        rule = Semantics.Rule(head, body)