[pypy-commit] lang-smalltalk default: (lwassermann) implemented another test
timfel
noreply at buildbot.pypy.org
Mon Feb 18 18:23:39 CET 2013
Author: Tim Felgentreff <timfelgentreff at gmail.com>
Branch:
Changeset: r53:403b4d8766ca
Date: 2013-02-18 18:17 +0100
http://bitbucket.org/pypy/lang-smalltalk/changeset/403b4d8766ca/
Log: (lwassermann) implemented another test implemented bytecode 138
diff --git a/spyvm/interpreter.py b/spyvm/interpreter.py
--- a/spyvm/interpreter.py
+++ b/spyvm/interpreter.py
@@ -370,14 +370,14 @@
# closure bytecodes
def pushNewArrayPopIntoArray(self, interp):
- popIntoArray, arraySize = splitter[1, 7](self.getbytecode())
+ arraySize, popIntoArray = splitter[7, 1](self.getbytecode())
newArray = None
- #if popIntoArray == 1:
- # newArray = interp.space.wrap_list(self.pop_and_return_n(arraySize))
- #else:
- # newArray = interp.space.w_Array.as_class_get_shadow(interp.space).new(arraySize)
+ if popIntoArray == 1:
+ newArray = interp.space.wrap_list(self.pop_and_return_n(arraySize))
+ else:
+ newArray = interp.space.w_Array.as_class_get_shadow(interp.space).new(arraySize)
self.push(newArray)
- raise MissingBytecode("not yet implemented: pushNewArray")
+ # raise MissingBytecode("not yet implemented: pushNewArray")
def experimentalBytecode(self, interp):
raise MissingBytecode("experimentalBytecode")
diff --git a/spyvm/objspace.py b/spyvm/objspace.py
--- a/spyvm/objspace.py
+++ b/spyvm/objspace.py
@@ -207,7 +207,7 @@
lstlen = len(lst_w)
res = self.w_Array.as_class_get_shadow(self).new(lstlen)
for i in range(lstlen):
- res.storevarpointer(i, lst_w[i])
+ res.atput0(self, i, lst_w[i])
return res
def unwrap_int(self, w_value):
diff --git a/spyvm/test/test_interpreter.py b/spyvm/test/test_interpreter.py
--- a/spyvm/test/test_interpreter.py
+++ b/spyvm/test/test_interpreter.py
@@ -832,11 +832,21 @@
# Closure Bytecodes
def test_bc_pushNewArrayPopIntoArray(bytecode=pushNewArrayPopIntoArray):
- py.test.skip("Fails, since pushNewArrayPopIntoArray is not yet implemented")
interp = new_interpreter(bytecode + chr(0x83))
context = interp.s_active_context()
- context.push(fakeliterals("egg"))
- context.push(fakeliterals("bar"))
- context.push(fakeliterals("baz"))
+ context.push(fakeliterals(space, "egg"))
+ context.push(fakeliterals(space, "bar"))
+ context.push(fakeliterals(space, "baz"))
interp.step(interp.s_active_context())
- assert context.pop() == fakeliterals(["egg", "bar", "baz"])
+ array = context.pop()
+ assert array.at0(space, 0) == fakeliterals(space, "egg")
+ assert array.at0(space, 1) == fakeliterals(space, "bar")
+ assert array.at0(space, 2) == fakeliterals(space, "baz")
+
+def test_bc_pushNewArray(bytecode=pushNewArrayPopIntoArray):
+ interp = new_interpreter(bytecode + chr(0x07))
+ context = interp.s_active_context()
+ interp.step(interp.s_active_context())
+ array = context.pop()
+ assert array.size() == 7
+ assert array.at0(space, 0) == space.w_nil
More information about the pypy-commit
mailing list