diff markup/tests/eval.py @ 87:1b874f032bde trunk

Fix some problems in expression evaluation by transforming the AST and compiling that to bytecode, instead of generating bytecode directly. Invalidates #13.
author cmlenz
date Mon, 17 Jul 2006 15:08:53 +0000
parents d60486018004
children 628ba9ed39ef
line wrap: on
line diff
--- a/markup/tests/eval.py
+++ b/markup/tests/eval.py
@@ -173,6 +173,13 @@
         self.assertEqual(True, Expression("x != y == y").evaluate({'x': 1,
                                                                    'y': 3}))
 
+    def test_call_function(self):
+        self.assertEqual(42, Expression("foo()").evaluate({'foo': lambda: 42}))
+        data = {'foo': 'bar'}
+        self.assertEqual('BAR', Expression("foo.upper()").evaluate(data))
+        data = {'foo': {'bar': range(42)}}
+        self.assertEqual(42, Expression("len(foo.bar)").evaluate(data))
+
     # FIXME: need support for local names in comprehensions
     #def test_list_comprehension(self):
     #    expr = Expression("[n for n in numbers if n < 2]")
Copyright (C) 2012-2017 Edgewall Software