changeset 163:0b1c4d4961af

test: Made test of the syntactic sugar we want to introduce.
author Sigurd Meldgaard <stm@daimi.au.dk>
date Wed, 09 Dec 2009 12:48:05 +0100
parents 427fbd7bd36b
children 0cdf99ec5204
files pysmcl/test/unit/test_sugar.py
diffstat 1 files changed, 35 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pysmcl/test/unit/test_sugar.py	Wed Dec 09 12:48:05 2009 +0100
@@ -0,0 +1,35 @@
+import unittest
+from pysmcl.ast_wrapper import parse
+from pysmcl.pretty_print import pprint_string
+from pysmcl.runtime_sugar import runtime_sugar
+
+
+class SecretIfTest(unittest.TestCase):
+
+    def test1(self):
+        program = """\
+def f():
+    a = input(3)
+    b = get("Nr:")
+    c = output(a + b[0])
+    print c
+"""
+        expected = """\
+def f(runtime):
+    a = runtime.input(3)
+    b = get(runtime, "Nr:")
+    c = runtime.output(a + b[0])
+    print c
+"""
+
+        self.make_test(program, expected)
+
+    def make_test(self, program, expected):
+        parsed = parse(program)
+        f = parsed.body[0]
+        runtime_sugar(f)
+        result = pprint_string(f)
+        self.assertEquals(expected, result)
+
+if __name__ == '__main__':
+    unittest.main()