2 files changed, 60 insertions(+)
viff/test/sfdl/__init__.py     |   16 ++++++++++++++
viff/test/sfdl/test_grammar.py |   44 ++++++++++++++++++++++++++++++++++++++++


# HG changeset patch
# User Martin Geisler <[EMAIL PROTECTED]>
# Date 1227518456 -3600
# Node ID c2211d5ab86f58e451cb23f1a5b47068319b9d08
# Parent  14a1378185796f4db0fdafe46ee4c774017eb49e
Test parsing empty programs.

diff --git a/viff/test/sfdl/__init__.py b/viff/test/sfdl/__init__.py
new file mode 100644
--- /dev/null
+++ b/viff/test/sfdl/__init__.py
@@ -0,0 +1,16 @@
+# Copyright 2008 VIFF Development Team.
+#
+# This file is part of VIFF, the Virtual Ideal Functionality Framework.
+#
+# VIFF is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License (LGPL) as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# VIFF is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
+# Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with VIFF. If not, see <http://www.gnu.org/licenses/>.
diff --git a/viff/test/sfdl/test_grammar.py b/viff/test/sfdl/test_grammar.py
new file mode 100644
--- /dev/null
+++ b/viff/test/sfdl/test_grammar.py
@@ -0,0 +1,44 @@
+# Copyright 2008 VIFF Development Team.
+#
+# This file is part of VIFF, the Virtual Ideal Functionality Framework.
+#
+# VIFF is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License (LGPL) as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# VIFF is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
+# Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with VIFF. If not, see <http://www.gnu.org/licenses/>.
+
+from twisted.trial.unittest import TestCase
+
+try:
+    from pyparsing import ParseException
+    from viff.sfdl.grammar import SFDLGrammar
+except ImportError:
+    SFDLGrammar = None
+
+class TestGrammar(TestCase):
+
+    def assertParse(self, parser, src, expected):
+        result = parser.parseString(src)
+        self.assertEquals(result.asList(), expected)
+
+    def assertNoParse(self, parser, src):
+        self.assertRaises(ParseException, parser.parseString, src)
+
+    def setUp(self):
+        self.grammar = SFDLGrammar()
+
+    def test_empty(self):
+        self.assertParse(self.grammar.program, "program empty {}",
+                         ['program', 'empty'])
+        self.assertNoParse(self.grammar.program, "program {}")
+
+if SFDLGrammar is None:
+    TestGrammar.skip = "Could not import SFDLGrammar, missing pyparsing?"
_______________________________________________
viff-patches mailing list
viff-patches@viff.dk
http://lists.viff.dk/listinfo.cgi/viff-patches-viff.dk

Reply via email to