From dcac7254f3fc24cde44af516374b0b3ce3881481 Mon Sep 17 00:00:00 2001 From: "jordi.saludes" Date: Tue, 27 Jul 2010 15:42:48 +0000 Subject: Added 'functions' and 'functionType' to py-bindings. --- contrib/py-bindings/test.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'contrib/py-bindings/test.py') diff --git a/contrib/py-bindings/test.py b/contrib/py-bindings/test.py index 04adb2c29..8b1bc9443 100644 --- a/contrib/py-bindings/test.py +++ b/contrib/py-bindings/test.py @@ -72,7 +72,16 @@ class TestPgfInfo(unittest.TestCase): for lang in 'QueryEng QuerySpa'.split(): l = gf.read_language(lang) self.assertEqual(rmprefix(l),lang) - + def test_functions(self): + pgf = self.pgf() + self.assertTrue('Even' in [`f` for f in pgf.functions()]) + def test_function_types(self): + pgf = self.pgf() + gftypes = dict((`f`,`pgf.fun_type(f)`) for f in pgf.functions()) + for p in "Prime : Object -> Question; Yes : Answer".split(';'): + lhs,rhs = [s.strip() for s in p.split(':')] + self.assertEqual(gftypes[lhs],rhs) + class TestParsing(unittest.TestCase): def setUp(self): self.lexed = samples @@ -154,5 +163,6 @@ class TestUnapplyExpr(unittest.TestCase): if type(uexp) != type(2) and type(uexp) != type('2'): exp = uexp[1] + if __name__ == '__main__': unittest.main() -- cgit v1.2.3