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

arigo at codespeak.net arigo at codespeak.net
Fri Aug 3 20:23:49 CEST 2007


Author: arigo
Date: Fri Aug  3 20:23:48 2007
New Revision: 45481

Modified:
   pypy/dist/pypy/lang/scheme/test/test_macro.py
Log:
Hygienic macro tests from http://sisc-scheme.org/r5rs_pitfall.scm.
One of them fails.


Modified: pypy/dist/pypy/lang/scheme/test/test_macro.py
==============================================================================
--- pypy/dist/pypy/lang/scheme/test/test_macro.py	(original)
+++ pypy/dist/pypy/lang/scheme/test/test_macro.py	Fri Aug  3 20:23:48 2007
@@ -440,7 +440,7 @@
             "(x y 1 2 3 4 + end)"
 
 def test_cornercase1():
-    py.test.skip("in-progress")
+    py.test.skip("currently crashes")
     w_result = eval_noctx("""(let-syntax ((foo (syntax-rules ()
                                                  ((bar) 'bar))))
                                (foo))
@@ -450,3 +450,38 @@
     # the R5RS, because it says that the keyword bar in the syntax rule
     # pattern should be ignored during matching and not be a pattern
     # variable.  But MIT-Scheme disagrees with me...
+
+# some tests from http://sisc-scheme.org/r5rs_pitfall.scm
+def test_pitfall_3_1():
+    w_result = eval_noctx("""(let-syntax ((foo (syntax-rules ()
+                                              ((_ expr) (+ expr 1)))))
+                                (let ((+ *))
+                                  (foo 3)))""")
+    assert w_result.to_number() == 4
+
+def test_pitfall_3_2():
+    py.test.skip("(cond ...) not implemented yet")
+    w_result = eval_noctx("""(let-syntax ((foo (syntax-rules ()
+                                                   ((_ var) (define var 1)))))
+                                 (let ((x 2))
+                                   (begin (define foo +))
+                                   (cond (else (foo x))) 
+                                   x))""")
+    assert w_result.to_number() == 2
+
+def test_pitfall_3_3():
+    py.test.skip("currently fails")
+    w_result = eval_noctx("""
+      (let ((x 1))
+        (let-syntax
+            ((foo (syntax-rules ()
+                    ((_ y) (let-syntax
+                                 ((bar (syntax-rules ()
+                                       ((_) (let ((x 2)) y)))))
+                             (bar))))))
+          (foo x)))""")
+    assert w_result.to_number() == 1
+
+def test_pitfall_3_4():
+    w_result = eval_noctx("(let-syntax ((x (syntax-rules ()))) 1)")
+    assert w_result.to_number() == 1



More information about the Pypy-commit mailing list