示例#1
0
 def test_propvar(self):
     """
     Rendering a PropVar trivially renders just that PropVar in a tree on
     its own.
     """
     p = PropVar('p')
     self.assertEqual(p.getSubTree().render(), Qtree('p').render())
示例#2
0
 def test_propvar(self):
     """
     Rendering a PropVar trivially renders just that PropVar in a tree on
     its own.
     """
     p = PropVar('p')
     self.assertEqual(p.getSubTree().render(), Qtree('p').render())
示例#3
0
    def test_or(self):
        r"""
        Rendering an Or renders the Or expression in the root and branches on
        each of the subexpressions.

        Or(p, q)
          /  \
         p    q
        """
        p = Or(PropVar('p'), PropVar('q'))
        expectedOutput = Qtree("Or(p, q)", [Qtree("p"), Qtree("q")])
        self.assertEqual(p.getSubTree().render(), expectedOutput.render())
示例#4
0
    def test_and(self):
        r"""
        Rendering an And renders the And expression in the root and both of the
        conjuncts newline-separated in a single subtree.

        And(p, q)
           |
           p
           q
        """
        p = And(PropVar('p'), PropVar('q'))
        expectedOutput = Qtree("And(p, q)", [Qtree("p\nq")])
        self.assertEqual(p.getSubTree().render(), expectedOutput.render())
示例#5
0
 def test_complexOr(self):
     r"""
        Or(p, Or(z, q))
       /  \
      p  Or(z, q)
           /  \
          z    q
     """
     p = Or(PropVar('p'), (Or(PropVar('z'), PropVar('q'))))
     expectedOutput = Qtree(
         "Or(p, Or(z, q))",
         [Qtree("p"),
          Qtree("Or(z, q)", [Qtree("z"), Qtree("q")])])
     self.assertEqual(p.getSubTree().render(), expectedOutput.render())
示例#6
0
    def test_complexQuadrupalAnd(self):
        r"""
        And(And(And(a, b), And(c, d), And(And(e, f), And(g, h))))
         |
        And(And(a, b), And(c, d))
        And(And(e, f), And(g, h))
         |
        And(a, b)
        And(c, d)
         |
        And(e, f)
        And(g, h)
         |
         a
         b - c d - e f - g h
        """
        l = And(And(PropVar('a'), PropVar('b')), And(PropVar('c'),
                                                     PropVar('d')))
        r = And(And(PropVar('e'), PropVar('f')), And(PropVar('g'),
                                                     PropVar('h')))
        p = And(l, r)

        expectedOutput = (
            '[.{And(And(And(a, b), And(c, d)), And(And(e, f), And(g, h)))} '
            '[.{And(And(a, b), And(c, d))\\\\And(And(e, f), And(g, h))} '
            '[.{And(a, b)\\\\And(c, d)} [.{a\\\\b} [.{c\\\\d} '
            '[.{And(e, f)\\\\And(g, h)} [.{e\\\\f} [.{g\\\\h}  ] ] ] ] ] ] ] ]'
        )

        actual = p.getSubTree().render()
        expected = expectedOutput
        self._renderDebugOutput(actual, expected)
        self.assertEqual(actual, expected)
示例#7
0
 def test_complexAnd(self):
     r"""
     And(And(p, q), r)
      |
     And(p, q)
      r
      |
      p
      q
     """
     p = And(And(PropVar('p'), PropVar('q')), PropVar('r'))
     expectedOutput = Qtree("And(And(p, q), r)",
                            [Qtree("And(p, q)\nr", [Qtree("p\nq")])])
     actual = p.getSubTree().render()
     expected = expectedOutput.render()
     self.assertEqual(actual, expected)
示例#8
0
 def test_complexAndRightHand(self):
     r"""
     And(r, And(p, q))
      |
      r
     And(p, q)
      |
      p
      q
     """
     p = And(PropVar('r'), And(PropVar('p'), PropVar('q')))
     expectedOutput = Qtree("And(r, And(p, q))",
                            [Qtree("r\nAnd(p, q)", [Qtree("p\nq")])])
     actual = p.getSubTree().render()
     expected = expectedOutput.render()
     self.assertEqual(actual, expected)
示例#9
0
 def test_complexDoubleAnd(self):
     r"""
     And(And(a, b), And(c, d))
      |
     And(a, b)
     And(c, d)
      |
      a
      b
      |
      c
      d
     """
     p = And(And(PropVar('a'), PropVar('b')), And(PropVar('c'),
                                                  PropVar('d')))
     expectedOutput = Qtree(
         "And(And(a, b), And(c, d))",
         [Qtree("And(a, b)\nAnd(c, d)", [Qtree("a\nb", [Qtree("c\nd")])])])
     actual = p.getSubTree().render()
     expected = expectedOutput.render()
     self.assertEqual(actual, expected)
示例#10
0
def p_compound_prop_PROP_VAR(p):
    "compound_prop : PROP_VAR"
    p[0] = PropVar(p[1])