[pypy-svn] r65305 - in pypy/branch/io-lang/pypy/lang/io: . test

david at codespeak.net david at codespeak.net
Tue May 19 12:15:46 CEST 2009


Author: david
Date: Tue May 19 12:15:43 2009
New Revision: 65305

Added:
   pypy/branch/io-lang/pypy/lang/io/test/test_number.py
Modified:
   pypy/branch/io-lang/pypy/lang/io/model.py
   pypy/branch/io-lang/pypy/lang/io/test/test_method.py
Log:
fixed issued evaluating variables in methods in the context of other objects than the Lobby

Modified: pypy/branch/io-lang/pypy/lang/io/model.py
==============================================================================
--- pypy/branch/io-lang/pypy/lang/io/model.py	(original)
+++ pypy/branch/io-lang/pypy/lang/io/model.py	Tue May 19 12:15:43 2009
@@ -110,7 +110,7 @@
             w_result = w_method.apply(space, w_receiver, self, w_context)
         if self.next:
             #TODO: optimize
-            return self.next.eval(space, w_result, w_context)
+            return self.next.eval(space, w_result, w_receiver)
         else:
             return w_result
   

Modified: pypy/branch/io-lang/pypy/lang/io/test/test_method.py
==============================================================================
--- pypy/branch/io-lang/pypy/lang/io/test/test_method.py	(original)
+++ pypy/branch/io-lang/pypy/lang/io/test/test_method.py	Tue May 19 12:15:43 2009
@@ -50,4 +50,25 @@
 def test_call_on_method():
     inp = 'a := method(x, x + 1); getSlot("a") call(3)'
     res, space = interpret(inp)
-    assert res.value == 4
\ No newline at end of file
+    assert res.value == 4
+    
+def test_method_binding():
+    inp = 'c := Object clone; c setSlot("b", 123); c setSlot("a", method(b)); c a'
+    res, space = interpret(inp)
+    assert res.value == 123
+    
+def test_method_modified_binding():
+    inp = 'c := Object clone; c setSlot("b",123); c setSlot("a", method(x, b)); c setSlot("b",1); c a(3)'
+    res, space = interpret(inp)
+    assert res.value == 1
+
+
+def test_block_binding():
+    inp = 'c := Object clone; b := 123; c setSlot("a", block(x, b)); c a call(3)'
+    res, space = interpret(inp)
+    assert res.value == 123
+
+def test_block_modified_binding():
+    inp = 'c := Object clone; b := 42; c setSlot("a", block(x, b)); b := 1; c a call(3)'
+    res, space = interpret(inp)
+    assert res.value == 1
\ No newline at end of file

Added: pypy/branch/io-lang/pypy/lang/io/test/test_number.py
==============================================================================
--- (empty file)
+++ pypy/branch/io-lang/pypy/lang/io/test/test_number.py	Tue May 19 12:15:43 2009
@@ -0,0 +1,31 @@
+from pypy.lang.io.parserhack import interpret
+from pypy.lang.io.model import W_Number
+import py
+def test_even_simpler():
+    x, _ = interpret("2")
+    assert x.value == 2
+
+def test_simple():
+    x, _ = interpret("2 + 2")
+    assert x.value == 4
+    
+def test_simple_minus():
+    x, _ = interpret("2 - 2")
+    assert x.value == 0
+
+def test_plus_in_context():
+    x, _ = interpret("""x := 7
+    c := method(2 - x)
+    c()
+    """)
+    assert x.value == -5
+    
+def test_plus_in_method():
+    inp = """c := Object clone
+    c f := 5
+    c g := method(3 + f)
+    c g(7)
+    """
+    res, space = interpret(inp)
+    assert res.value == 8
+    



More information about the Pypy-commit mailing list