[pypy-svn] r66636 - in pypy/branch/io-lang/pypy/lang/io: . test
david at codespeak.net
david at codespeak.net
Sun Jul 26 17:43:57 CEST 2009
Author: david
Date: Sun Jul 26 17:43:56 2009
New Revision: 66636
Modified:
pypy/branch/io-lang/pypy/lang/io/object.py
pypy/branch/io-lang/pypy/lang/io/objspace.py
pypy/branch/io-lang/pypy/lang/io/test/test_object.py
Log:
improved Object continue
Modified: pypy/branch/io-lang/pypy/lang/io/object.py
==============================================================================
--- pypy/branch/io-lang/pypy/lang/io/object.py (original)
+++ pypy/branch/io-lang/pypy/lang/io/object.py Sun Jul 26 17:43:56 2009
@@ -80,7 +80,7 @@
body = w_message.arguments[-1]
start = w_message.arguments[1].eval(space, w_target, w_context).value
- stop = w_message.arguments[2].eval(space, w_target, w_context).value
+ stop = 1 + w_message.arguments[2].eval(space, w_target, w_context).value
if argcount == 4:
step = 1
else:
@@ -93,7 +93,7 @@
for i in range(start, stop, step):
w_context.slots[key] = W_Number(space, i)
t = body.eval(space, w_context, w_context)
- if not space.is_normal_status():
+ if not space.is_normal_status() and not space.is_continue_status():
space.normal_status()
break
return t
Modified: pypy/branch/io-lang/pypy/lang/io/objspace.py
==============================================================================
--- pypy/branch/io-lang/pypy/lang/io/objspace.py (original)
+++ pypy/branch/io-lang/pypy/lang/io/objspace.py Sun Jul 26 17:43:56 2009
@@ -154,7 +154,11 @@
def continue_status(self):
self.stop_status = self.w_continue
-
+
+ def is_continue_status(self):
+ return self.stop_status == self.w_continue
+
def return_status(self, result):
self.stop_status = self.w_return
- self.w_return_value = result
\ No newline at end of file
+ self.w_return_value = result
+
Modified: pypy/branch/io-lang/pypy/lang/io/test/test_object.py
==============================================================================
--- pypy/branch/io-lang/pypy/lang/io/test/test_object.py (original)
+++ pypy/branch/io-lang/pypy/lang/io/test/test_object.py Sun Jul 26 17:43:56 2009
@@ -139,9 +139,10 @@
def test_object_continue():
inp = """a := list()
for(x, 1, 10, continue; a append(x))
- a"""
+ """
res, space = interpret(inp)
- assert len(res.items) == 0
+ assert space.w_lobby.slots['x'].value == 10
+ assert len(space.w_lobby.slots['a'].items) == 0
def test_object_return():
inp = """x := method(y, return)
@@ -165,4 +166,4 @@
inp = """x := method(y, return(1024); 666)
x(99)"""
res, space = interpret(inp)
- assert res.value == 1024
\ No newline at end of file
+ assert res.value == 1024
More information about the Pypy-commit
mailing list