def test_multiline(self):
     """
     Terms spread across multiple lines are parsed correctly.
     """
     single = parseTerm('foo(baz({x: "y", boz: 42}))')
     multi = parseTerm("""foo(
                 baz({
                  x: "y",
                  boz: 42}
                ))""")
     self.assertEqual(multi, single)
Exemple #2
0
 def test_multiline(self):
     """
     Terms spread across multiple lines are parsed correctly.
     """
     single = parseTerm('foo(baz({x: "y", boz: 42}))')
     multi = parseTerm(
             """foo(
                 baz({
                  x: "y",
                  boz: 42}
                ))""")
     self.assertEqual(multi, single)
 def test_coerce(self):
     self.assertEqual(
         coerceToTerm({
             3: 4,
             "a": character('x'),
             (2, 3): [4, 5]
         }), parseTerm('{"a": \'x\', 3: 4, [2, 3]: [4, 5]}'))
Exemple #4
0
 def _m_audit(self, auditors):
     expr = parseTerm(self._m_objectExpr.decode('base64').decode('zlib'))
     for auditor in auditors:
         pass
 def test_make(self):
     m = TermMaker()
     t1 = m.Foo(1, 'a', m.Baz())
     self.assertEqual(t1, parseTerm('Foo(1, "a", Baz)'))
Exemple #6
0
 def test_coerce(self):
     self.assertEqual(
         coerceToTerm({3: 4, "a": character('x'), (2, 3): [4, 5]}),
         parseTerm('{"a": \'x\', 3: 4, [2, 3]: [4, 5]}'))
 def assertRoundtrip(txt):
     self.assertEqual('term(%r)' % (txt,), repr(parseTerm(txt)))
    def test_fullTerm(self):
        """
        Shortcut syntax for terms is handled.
        """

        self.assertEqual(parseTerm("[x, y, 1]"), parseTerm(".tuple.(x, y, 1)"))
        self.assertEqual(parseTerm("{x, y, 1}"), parseTerm(".bag.(x, y, 1)"))
        self.assertEqual(parseTerm("f {x, y, 1}"), parseTerm("f(.bag.(x, y, 1))"))
        self.assertEqual(parseTerm("a: b"), parseTerm(".attr.(a, b)"))
        self.assertEqual(parseTerm('"a": b'), parseTerm('.attr.("a", b)'))
        self.assertEqual(parseTerm('a: [b]'), parseTerm('.attr.(a, .tuple.(b))'))
Exemple #9
0
 def _m_audit(self, auditors):
     expr = parseTerm(self._m_objectExpr.decode('base64').decode('zlib'))
     for auditor in auditors:
         pass