[pypy-svn] r9108 - in pypy/branch/dist-interpapp/pypy/interpreter: . test

hpk at codespeak.net hpk at codespeak.net
Fri Feb 11 14:04:45 CET 2005


Author: hpk
Date: Fri Feb 11 14:04:45 2005
New Revision: 9108

Modified:
   pypy/branch/dist-interpapp/pypy/interpreter/gateway.py
   pypy/branch/dist-interpapp/pypy/interpreter/test/test_appinterp.py
Log:
fix ordering bug for default-handling code, 
add a test for that



Modified: pypy/branch/dist-interpapp/pypy/interpreter/gateway.py
==============================================================================
--- pypy/branch/dist-interpapp/pypy/interpreter/gateway.py	(original)
+++ pypy/branch/dist-interpapp/pypy/interpreter/gateway.py	Fri Feb 11 14:04:45 2005
@@ -715,7 +715,7 @@
     # (which does not imply that the code doing it is nice :-) 
     defaulthandlingsource = py.code.Source()
     while defaultargs: 
-        name, value = defaultargs.pop() 
+        name, value = defaultargs.pop(0) 
         defaulthandlingsource = defaulthandlingsource.putaround("""\
             if %s is None: 
                 %s = space.wrap(%s)

Modified: pypy/branch/dist-interpapp/pypy/interpreter/test/test_appinterp.py
==============================================================================
--- pypy/branch/dist-interpapp/pypy/interpreter/test/test_appinterp.py	(original)
+++ pypy/branch/dist-interpapp/pypy/interpreter/test/test_appinterp.py	Fri Feb 11 14:04:45 2005
@@ -32,7 +32,7 @@
     w_result = app(space, space.wrap(41), space.wrap(1))
     assert space.eq_w(w_result, space.wrap(42))
 
-def test_applevel_withdefault(space):
+def test_applevel_with_one_default(space):
     app = appdef("""app(x,y=1): 
         return x + y
     """)
@@ -40,6 +40,20 @@
     w_result = app(space, space.wrap(41)) 
     assert space.eq_w(w_result, space.wrap(42))
 
+def test_applevel_with_two_defaults(space):
+    app = appdef("""app(x=1,y=2): 
+        return x + y
+    """)
+    w_result = app(space, space.wrap(41), space.wrap(1))
+    assert space.eq_w(w_result, space.wrap(42))
+
+    w_result = app(space, space.wrap(15))
+    assert space.eq_w(w_result, space.wrap(17))
+
+    w_result = app(space)
+    assert space.eq_w(w_result, space.wrap(3))
+
+
 def test_applevel_noargs(space):
     app = appdef("""app(): 
         return 42 



More information about the Pypy-commit mailing list