[pypy-svn] r34585 - in pypy/dist/pypy/lang/prolog/interpreter: . test

cfbolz at codespeak.net cfbolz at codespeak.net
Mon Nov 13 22:04:15 CET 2006


Author: cfbolz
Date: Mon Nov 13 22:04:13 2006
New Revision: 34585

Modified:
   pypy/dist/pypy/lang/prolog/interpreter/term.py
   pypy/dist/pypy/lang/prolog/interpreter/test/test_engine.py
Log:
test and fix for calling functions without arguments.


Modified: pypy/dist/pypy/lang/prolog/interpreter/term.py
==============================================================================
--- pypy/dist/pypy/lang/prolog/interpreter/term.py	(original)
+++ pypy/dist/pypy/lang/prolog/interpreter/term.py	Mon Nov 13 22:04:13 2006
@@ -522,6 +522,12 @@
             extend_and_normalize_template_frame(template_frame, frame)
             for index, obj in to_instantiate:
                 frame.vars[index] = obj.instantiate_template(template_frame)
+        else:
+            next_free = frame.maxvar()
+            for i in range(self.numvars):
+                template_frame[i] = Var(next_free)
+                next_free += 1
+            frame.extend(next_free - frame.maxvar())
         body = self.body
         if body is None:
             return None

Modified: pypy/dist/pypy/lang/prolog/interpreter/test/test_engine.py
==============================================================================
--- pypy/dist/pypy/lang/prolog/interpreter/test/test_engine.py	(original)
+++ pypy/dist/pypy/lang/prolog/interpreter/test/test_engine.py	Mon Nov 13 22:04:13 2006
@@ -241,3 +241,12 @@
 
 def test_handle_non_callable():
     py.test.raises(CatchableError, assert_true, "1.")
+
+def test_call_atom():
+    e = get_engine("""
+        test(a).
+        test :- test(_).
+    """)
+    assert_true("test.", e)
+
+



More information about the Pypy-commit mailing list