[pypy-svn] r44697 - pypy/dist/pypy/lang/scheme/test

jlg at codespeak.net jlg at codespeak.net
Tue Jul 3 14:55:01 CEST 2007


Author: jlg
Date: Tue Jul  3 14:55:00 2007
New Revision: 44697

Modified:
   pypy/dist/pypy/lang/scheme/test/test_eval.py
Log:
test lambdas (context lookup)

Modified: pypy/dist/pypy/lang/scheme/test/test_eval.py
==============================================================================
--- pypy/dist/pypy/lang/scheme/test/test_eval.py	(original)
+++ pypy/dist/pypy/lang/scheme/test/test_eval.py	Tue Jul  3 14:55:00 2007
@@ -162,3 +162,20 @@
     assert isinstance(w_result, W_Fixnum)
     assert w_result.to_number() == 42
 
+    w_result = eval_expr(ctx, "((lambda (n m) (+ n m)) 42 -42)")
+    assert isinstance(w_result, W_Fixnum)
+    assert w_result.to_number() == 0
+
+def test_lambda_top_ctx():
+    ctx = ExecutionContext()
+    eval_expr(ctx, "(define n 42)")
+    eval_expr(ctx, "(define f1 (lambda (m) (+ n m)))")
+    w_result = eval_expr(ctx, "(f1 -42)")
+    assert isinstance(w_result, W_Fixnum)
+    assert w_result.to_number() == 0
+
+    eval_expr(ctx, "(define n 84)")
+    w_result = eval_expr(ctx, "(f1 -42)")
+    assert isinstance(w_result, W_Fixnum)
+    assert w_result.to_number() == 42
+



More information about the Pypy-commit mailing list