[pypy-svn] r51767 - in pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk: . test
tverwaes at codespeak.net
tverwaes at codespeak.net
Fri Feb 22 04:28:45 CET 2008
Author: tverwaes
Date: Fri Feb 22 04:28:42 2008
New Revision: 51767
Modified:
pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/interpreter.py
pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/model.py
pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/primitives.py
pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/shadow.py
pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/test/test_interpreter.py
pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/test/test_miniimage.py
pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/test/test_primitives.py
pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/test/test_shadow.py
Log:
getting all the numbers and tests right. added a test which restarts the
suspended thread of the image
Modified: pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/interpreter.py
==============================================================================
--- pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/interpreter.py (original)
+++ pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/interpreter.py Fri Feb 22 04:28:42 2008
@@ -61,7 +61,7 @@
print "%sStack=%s" % (
self._last_indent,
- repr(self.s_active_context.stack),)
+ repr(self.s_active_context.stack()),)
print "%sBytecode at %d (%d:%s):" % (
self._last_indent,
self.s_active_context.pc(),
@@ -171,7 +171,7 @@
if interp.should_trace():
print "%sSending selector %r to %r with: %r" % (
interp._last_indent, selector, receiver,
- [self.stack[i-argcount] for i in range(argcount)])
+ [self.peek(argcount-1-i) for i in range(argcount)])
pass
assert argcount >= 0
method = receiverclassshadow.lookup(selector)
Modified: pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/model.py
==============================================================================
--- pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/model.py (original)
+++ pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/model.py Fri Feb 22 04:28:42 2008
@@ -406,7 +406,7 @@
self.primitive is not None)
def size(self):
- return self.getliteralsize() + len(self.bytes) + self.headersize()
+ return self.headersize() + self.getliteralsize() + len(self.bytes)
def getliteralsize(self):
return self.literalsize * constants.BYTES_PER_WORD
@@ -453,7 +453,6 @@
def fetchbyte(self, index1):
index0 = index1 - 1
- index0 -= self.headersize()
index0 -= self.getliteralsize()
assert index0 < len(self.bytes)
return self.bytes[index0]
@@ -493,7 +492,7 @@
__metaclass__ = extendabletype
def __init__(self, s_home, s_sender):
- self.stack = []
+ self._stack = []
self._pc = 0
#assert isinstance(s_home, W_MethodContext)
self._s_home = s_home
@@ -511,6 +510,9 @@
def pc(self):
return self._pc
+ def stack(self):
+ return self._stack
+
def store_pc(self, pc):
self._pc = pc
@@ -529,45 +531,44 @@
self._s_sender = s_sender
def stackpointer(self):
- return len(self.stack) + self.stackstart()
+ return len(self.stack()) + self.stackstart() - 1
# ______________________________________________________________________
# Imitate the primitive accessors
- #def fetch(self, index):
- # from pypy.lang.smalltalk import utility, objtable
- # if index == constants.CTXPART_SENDER_INDEX:
- # sender = self.s_sender()
- # if sender is None:
- # return objtable.w_nil
- # else:
- # return sender.w_self()
- # elif index == constants.CTXPART_PC_INDEX:
- # return utility.wrap_int(self.pc())
- # elif index == constants.CTXPART_STACKP_INDEX:
- # return utility.wrap_int(self.stackpointer())
- #
- # # Invalid!
- # raise IndexError
+ def fetch(self, index):
+ from pypy.lang.smalltalk import utility, objtable
+ if index == constants.CTXPART_SENDER_INDEX:
+ sender = self.s_sender()
+ if sender is None:
+ return objtable.w_nil
+ else:
+ return sender.w_self()
+ elif index == constants.CTXPART_PC_INDEX:
+ return utility.wrap_int(self.pc())
+ elif index == constants.CTXPART_STACKP_INDEX:
+ return utility.wrap_int(self.stackpointer())
+
+ # Invalid!
+ raise IndexError
- #def store(self, index, w_value):
- # # XXX Untested code...
- #
- # from pypy.lang.smalltalk import utility, objtable
- # if index == constants.CTXPART_SENDER_INDEX:
- # if w_value != objtable.w_nil:
- # self._s_sender = w_value.as_context_get_shadow()
- # elif index == constants.CTXPART_PC_INDEX:
- # self._pc = utility.unwrap_int(w_value)
- # elif index == constants.CTXPART_STACKP_INDEX:
- # size = utility.unwrap_int(w_value)
- # size = size - self.stackstart()
- # self.stack = [objtable.w_nil] * size
- # else:
- # # Invalid!
- # raise IndexError
+ def store(self, index, w_value):
+ # XXX Untested code...
+ from pypy.lang.smalltalk import utility, objtable
+ if index == constants.CTXPART_SENDER_INDEX:
+ if w_value != objtable.w_nil:
+ self._s_sender = w_value.as_context_get_shadow()
+ elif index == constants.CTXPART_PC_INDEX:
+ self._pc = utility.unwrap_int(w_value)
+ elif index == constants.CTXPART_STACKP_INDEX:
+ size = utility.unwrap_int(w_value)
+ size = 1 + size - self.stackstart()
+ self._stack = [objtable.w_nil] * size
+ else:
+ # Invalid!
+ raise IndexError
def stackstart(self):
- return self.w_method().argsize + self.w_method().tempsize + constants.MTHDCTX_TEMP_FRAME_START
+ return constants.MTHDCTX_TEMP_FRAME_START
# ______________________________________________________________________
# Method that contains the bytecode for this method/block context
@@ -601,35 +602,35 @@
# Stack Manipulation
def pop(self):
- return self.stack.pop()
+ return self.stack().pop()
def push(self, w_v):
assert w_v
- self.stack.append(w_v)
+ self.stack().append(w_v)
def push_all(self, lst):
" Equivalent to 'for x in lst: self.push(x)' where x is a lst "
assert None not in lst
- self.stack += lst
+ self._stack += lst
def top(self):
return self.peek(0)
def peek(self, idx):
- return self.stack[-(idx+1)]
+ return self.stack()[-(idx+1)]
def pop_n(self, n):
assert n >= 0
- start = len(self.stack) - n
+ start = len(self.stack()) - n
assert start >= 0 # XXX what if this fails?
- del self.stack[start:]
+ del self.stack()[start:]
def pop_and_return_n(self, n):
assert n >= 0
- start = len(self.stack) - n
+ start = len(self.stack()) - n
assert start >= 0 # XXX what if this fails?
- res = self.stack[start:]
- del self.stack[start:]
+ res = self.stack()[start:]
+ del self.stack()[start:]
return res
class W_BlockContext(W_ContextPart):
@@ -662,8 +663,8 @@
elif index == constants.BLKCTX_HOME_INDEX:
return self.s_home()
elif index >= constants.BLKCTX_TEMP_FRAME_START:
- stack_index = len(self.stack) - index - 1
- return self.stack[stack_index]
+ stack_index = len(self.stack()) - index - 1
+ return self.stack()[stack_index]
else:
return W_ContextPart.fetch(self, index)
@@ -678,11 +679,14 @@
elif index == constants.BLKCTX_HOME_INDEX:
self._s_home = value.as_methodcontext_get_shadow()
elif index >= constants.BLKCTX_TEMP_FRAME_START:
- stack_index = len(self.stack) - index - 1
- self.stack[stack_index] = value
+ stack_index = len(self.stack()) - index - 1
+ self.stack()[stack_index] = value
else:
W_ContextPart.store(self, index, value)
+ def stackstart(self):
+ return constants.BLKCTX_TEMP_FRAME_START
+
class W_MethodContext(W_ContextPart):
def __init__(self, w_method, w_receiver,
arguments, s_sender=None):
@@ -720,8 +724,8 @@
# After that comes the stack:
offset -= len(self.temps)
- stack_index = len(self.stack) - offset - 1
- return self.stack[stack_index]
+ stack_index = len(self.stack()) - offset - 1
+ return self.stack()[stack_index]
else:
return W_ContextPart.fetch(self, index)
@@ -740,8 +744,8 @@
# After that comes the stack:
offset -= len(self.temps)
- stack_index = len(self.stack) - offset - 1
- self.stack[stack_index] = w_object
+ stack_index = len(self.stack()) - offset - 1
+ self.stack()[stack_index] = w_object
else:
W_ContextPart.store(self, index, w_object)
Modified: pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/primitives.py
==============================================================================
--- pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/primitives.py (original)
+++ pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/primitives.py Fri Feb 22 04:28:42 2008
@@ -79,12 +79,12 @@
argument_count = argument_count_m1 + 1 # to account for the rcvr
frame = interp.s_active_context
assert argument_count == len_unwrap_spec
- if frame.stackpointer() - frame.stackstart() < len_unwrap_spec:
+ if frame.stackpointer() - frame.stackstart() + 1 < len_unwrap_spec:
raise PrimitiveFailedError()
args = ()
for i, spec in unrolling_unwrap_spec:
- index = -len_unwrap_spec + i
- w_arg = frame.stack[index]
+ index = len_unwrap_spec - 1 - i
+ w_arg = frame.peek(index)
if spec is int:
args += (utility.unwrap_int(w_arg), )
elif spec is index1_0:
Modified: pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/shadow.py
==============================================================================
--- pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/shadow.py (original)
+++ pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/shadow.py Fri Feb 22 04:28:42 2008
@@ -473,6 +473,9 @@
assert n <= self.stackpointer() + 1
self.store_stackpointer(self.stackpointer() - n)
+ def stack(self):
+ return [self.w_self().fetch(i) for i in range(self.stackstart(), self.stackpointer() + 1)]
+
def pop_and_return_n(self, n):
self.pop_n(n)
start = self.stackpointer() + 1
@@ -522,4 +525,4 @@
return self
def stackstart(self):
- return self.w_method().argsize + self.w_method().tempsize + constants.MTHDCTX_TEMP_FRAME_START
+ return constants.MTHDCTX_TEMP_FRAME_START
Modified: pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/test/test_interpreter.py
==============================================================================
--- pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/test/test_interpreter.py (original)
+++ pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/test/test_interpreter.py Fri Feb 22 04:28:42 2008
@@ -129,7 +129,7 @@
interp.step()
interp.step()
interp.step()
- assert interp.s_active_context.stack == ["egg", "bar", "baz"]
+ assert interp.s_active_context.stack() == ["egg", "bar", "baz"]
def test_pushTemporaryVariableBytecode(bytecode=(pushTemporaryVariableBytecode(0) +
pushTemporaryVariableBytecode(1) +
@@ -139,7 +139,7 @@
interp.step()
interp.step()
interp.step()
- assert interp.s_active_context.stack == ["foo", "bar", "temp"]
+ assert interp.s_active_context.stack() == ["foo", "bar", "temp"]
def test_pushLiteralConstantBytecode(bytecode=pushLiteralConstantBytecode(0) +
pushLiteralConstantBytecode(1) +
@@ -149,7 +149,7 @@
interp.step()
interp.step()
interp.step()
- assert interp.s_active_context.stack == [fakesymbol("a"),
+ assert interp.s_active_context.stack() == [fakesymbol("a"),
fakesymbol("b"),
fakesymbol("c")]
@@ -160,7 +160,7 @@
interp = new_interpreter(bytecode)
interp.s_active_context.w_method().literals = fakeliterals(w_association)
interp.step()
- assert interp.s_active_context.stack == ["myvalue"]
+ assert interp.s_active_context.stack() == ["myvalue"]
def test_storeAndPopReceiverVariableBytecode(bytecode=storeAndPopReceiverVariableBytecode,
popped=True):
@@ -172,9 +172,9 @@
interp.step()
interp.step()
if popped:
- assert interp.s_active_context.stack == []
+ assert interp.s_active_context.stack() == []
else:
- assert interp.s_active_context.stack == [interp.TRUE]
+ assert interp.s_active_context.stack() == [interp.TRUE]
for test_index in range(8):
if test_index == index:
@@ -188,7 +188,7 @@
interp.s_active_context.temps = [None] * 8
interp.step()
interp.step()
- assert interp.s_active_context.stack == []
+ assert interp.s_active_context.stack() == []
for test_index in range(8):
if test_index == index:
assert interp.s_active_context.temps[test_index] == interp.TRUE
@@ -199,55 +199,55 @@
interp = new_interpreter(pushConstantTrueBytecode)
interp.step()
assert interp.s_active_context.pop() == interp.TRUE
- assert interp.s_active_context.stack == []
+ assert interp.s_active_context.stack() == []
def test_pushConstantFalseBytecode():
interp = new_interpreter(pushConstantFalseBytecode)
interp.step()
assert interp.s_active_context.pop() == interp.FALSE
- assert interp.s_active_context.stack == []
+ assert interp.s_active_context.stack() == []
def test_pushConstantNilBytecode():
interp = new_interpreter(pushConstantNilBytecode)
interp.step()
assert interp.s_active_context.pop() == interp.NIL
- assert interp.s_active_context.stack == []
+ assert interp.s_active_context.stack() == []
def test_pushConstantMinusOneBytecode():
interp = new_interpreter(pushConstantMinusOneBytecode)
interp.step()
assert interp.s_active_context.pop() == interp.MINUS_ONE
- assert interp.s_active_context.stack == []
+ assert interp.s_active_context.stack() == []
def test_pushConstantZeroBytecode():
interp = new_interpreter(pushConstantZeroBytecode)
interp.step()
assert interp.s_active_context.pop() == interp.ZERO
- assert interp.s_active_context.stack == []
+ assert interp.s_active_context.stack() == []
def test_pushConstantOneBytecode():
interp = new_interpreter(pushConstantOneBytecode)
interp.step()
assert interp.s_active_context.pop() == interp.ONE
- assert interp.s_active_context.stack == []
+ assert interp.s_active_context.stack() == []
def test_pushConstantTwoBytecode():
interp = new_interpreter(pushConstantTwoBytecode)
interp.step()
assert interp.s_active_context.pop() == interp.TWO
- assert interp.s_active_context.stack == []
+ assert interp.s_active_context.stack() == []
def test_pushActiveContextBytecode():
interp = new_interpreter(pushActiveContextBytecode)
interp.step()
assert interp.s_active_context.pop() == interp.s_active_context.w_self()
- assert interp.s_active_context.stack == []
+ assert interp.s_active_context.stack() == []
def test_duplicateTopBytecode():
interp = new_interpreter(pushConstantZeroBytecode + duplicateTopBytecode)
interp.step()
interp.step()
- assert interp.s_active_context.stack == [interp.ZERO, interp.ZERO]
+ assert interp.s_active_context.stack() == [interp.ZERO, interp.ZERO]
def test_bytecodePrimBitAnd():
interp = new_interpreter(pushConstantOneBytecode + pushConstantTwoBytecode + bytecodePrimBitAnd)
@@ -255,7 +255,7 @@
interp.step()
interp.step()
assert interp.s_active_context.pop().value == 0
- assert interp.s_active_context.stack == []
+ assert interp.s_active_context.stack() == []
def test_bytecodePrimBitOr():
interp = new_interpreter(pushConstantOneBytecode + pushConstantTwoBytecode + bytecodePrimBitOr)
@@ -263,7 +263,7 @@
interp.step()
interp.step()
assert interp.s_active_context.pop().value == 3
- assert interp.s_active_context.stack == []
+ assert interp.s_active_context.stack() == []
def test_bytecodePrimBitShift():
interp = new_interpreter(pushConstantOneBytecode + pushConstantTwoBytecode + bytecodePrimBitShift)
@@ -271,14 +271,14 @@
interp.step()
interp.step()
assert interp.s_active_context.pop().value == 4
- assert interp.s_active_context.stack == []
+ assert interp.s_active_context.stack() == []
def test_bytecodePrimClass():
interp = new_interpreter(pushConstantOneBytecode + bytecodePrimClass)
interp.step()
interp.step()
assert interp.s_active_context.pop() == classtable.w_SmallInteger
- assert interp.s_active_context.stack == []
+ assert interp.s_active_context.stack() == []
def test_bytecodePrimSubtract():
interp = new_interpreter(pushConstantOneBytecode + pushConstantTwoBytecode + bytecodePrimSubtract)
@@ -286,7 +286,7 @@
interp.step()
interp.step()
assert interp.s_active_context.pop().value == -1
- assert interp.s_active_context.stack == []
+ assert interp.s_active_context.stack() == []
def test_bytecodePrimMultiply():
interp = new_interpreter(pushConstantMinusOneBytecode + pushConstantTwoBytecode + bytecodePrimMultiply)
@@ -294,7 +294,7 @@
interp.step()
interp.step()
assert interp.s_active_context.pop().value == -2
- assert interp.s_active_context.stack == []
+ assert interp.s_active_context.stack() == []
def test_bytecodePrimDivide():
interp = new_interpreter(pushConstantTwoBytecode + pushConstantMinusOneBytecode + bytecodePrimDivide)
@@ -302,7 +302,7 @@
interp.step()
interp.step()
assert interp.s_active_context.pop().value == -2
- assert interp.s_active_context.stack == []
+ assert interp.s_active_context.stack() == []
def test_bytecodePrimDiv():
interp = new_interpreter(pushConstantTwoBytecode + pushConstantMinusOneBytecode + bytecodePrimDiv)
@@ -310,7 +310,7 @@
interp.step()
interp.step()
assert interp.s_active_context.pop().value == -2
- assert interp.s_active_context.stack == []
+ assert interp.s_active_context.stack() == []
def test_bytecodePrimMod():
interp = new_interpreter(pushConstantTwoBytecode + pushConstantMinusOneBytecode + bytecodePrimMod)
@@ -318,7 +318,7 @@
interp.step()
interp.step()
assert interp.s_active_context.pop().value == 0
- assert interp.s_active_context.stack == []
+ assert interp.s_active_context.stack() == []
def test_bytecodePrimEquivalent():
interp = new_interpreter(pushConstantTwoBytecode + pushConstantMinusOneBytecode + bytecodePrimEquivalent)
@@ -326,14 +326,14 @@
interp.step()
interp.step()
assert interp.s_active_context.pop() == interpreter.Interpreter.FALSE
- assert interp.s_active_context.stack == []
+ assert interp.s_active_context.stack() == []
interp = new_interpreter(pushConstantOneBytecode + pushConstantOneBytecode + bytecodePrimEquivalent)
interp.step()
interp.step()
interp.step()
assert interp.s_active_context.pop() == interpreter.Interpreter.TRUE
- assert interp.s_active_context.stack == []
+ assert interp.s_active_context.stack() == []
def test_bytecodePrimNew():
w_fakeclassclass = mockclass(10, name='fakeclassclass')
@@ -345,7 +345,7 @@
[[w_fakeclassclass, primitives.NEW, 0, "new"]],
interp.step)
w_fakeinst = interp.s_active_context.pop()
- assert interp.s_active_context.stack == []
+ assert interp.s_active_context.stack() == []
assert w_fakeinst.getclass() == w_fakeclass
assert w_fakeinst.size() == 1
@@ -360,7 +360,7 @@
[[w_fakeclassclass, primitives.NEW_WITH_ARG, 1, "new:"]],
interp.step)
w_fakeinst = interp.s_active_context.pop()
- assert interp.s_active_context.stack == []
+ assert interp.s_active_context.stack() == []
assert w_fakeinst.getclass() == w_fakeclass
assert w_fakeinst.size() == 3
@@ -373,7 +373,7 @@
[[w_fakeclass, primitives.SIZE, 0, "size"]],
interp.step)
assert interp.s_active_context.pop().value == 5
- assert interp.s_active_context.stack == []
+ assert interp.s_active_context.stack() == []
# w_class - the class from which the method is going to be called
# (and on which it is going to be installed)
@@ -395,14 +395,14 @@
callerContext = interp.s_active_context
interp.step()
assert interp.s_active_context.s_sender() == callerContext
- assert interp.s_active_context.stack == []
+ assert interp.s_active_context.stack() == []
assert interp.s_active_context.w_receiver() == w_object
assert interp.s_active_context.w_method() == shadow.methoddict["foo"]
- assert callerContext.stack == []
+ assert callerContext.stack() == []
interp.step()
interp.step()
assert interp.s_active_context == callerContext
- assert interp.s_active_context.stack == [result]
+ assert interp.s_active_context.stack() == [result]
def test_sendLiteralSelectorBytecode():
w_class = mockclass(0)
@@ -436,7 +436,7 @@
callerContext = interp.s_active_context
interp.step()
assert interp.s_active_context is callerContext
- assert len(interp.s_active_context.stack) == 1
+ assert len(interp.s_active_context.stack()) == 1
w_result = interp.s_active_context.pop()
assert unwrap_int(w_result) == 42
@@ -496,9 +496,9 @@
interp = new_interpreter(pushConstantTrueBytecode +
popStackBytecode)
interp.step()
- assert interp.s_active_context.stack == [interp.TRUE]
+ assert interp.s_active_context.stack() == [interp.TRUE]
interp.step()
- assert interp.s_active_context.stack == []
+ assert interp.s_active_context.stack() == []
def test_extendedPushBytecode():
test_pushReceiverVariableBytecode(extendedPushBytecode + chr((0<<6) + 0) +
@@ -551,7 +551,7 @@
assert interp.s_active_context.w_method() == shadow.methoddict["+"]
assert interp.s_active_context.w_receiver() is w_object
assert interp.s_active_context.gettemp(0) == interp.ONE
- assert interp.s_active_context.stack == []
+ assert interp.s_active_context.stack() == []
def test_bytecodePrimBool():
interp = new_interpreter(bytecodePrimLessThan +
@@ -564,7 +564,7 @@
interp.s_active_context.push(interp.ONE)
interp.s_active_context.push(interp.TWO)
interp.step()
- assert interp.s_active_context.stack == [interp.TRUE, interp.FALSE,
+ assert interp.s_active_context.stack() == [interp.TRUE, interp.FALSE,
interp.TRUE, interp.FALSE,
interp.FALSE, interp.TRUE]
@@ -601,11 +601,11 @@
interp.step()
interp.step()
assert interp.s_active_context.s_sender() == callerContext
- assert interp.s_active_context.stack == []
+ assert interp.s_active_context.stack() == []
assert interp.s_active_context.w_receiver() == w_object
meth = w_specificclass.as_class_get_shadow().methoddict["foo"]
assert interp.s_active_context.w_method() == meth
- assert callerContext.stack == []
+ assert callerContext.stack() == []
def test_secondExtendedSendBytecode():
w_class = mockclass(0)
Modified: pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/test/test_miniimage.py
==============================================================================
--- pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/test/test_miniimage.py (original)
+++ pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/test/test_miniimage.py Fri Feb 22 04:28:42 2008
@@ -227,6 +227,7 @@
assert w_false is objtable.w_false
def test_runimage():
+ #py.test.skip("This method actually runs an image. Fails since no graphical primitives yet")
from pypy.lang.smalltalk.shadow import SemaphoreShadow
s_semaphore = SemaphoreShadow(None)
s_scheduler = s_semaphore.s_scheduler()
@@ -238,7 +239,7 @@
interp.interpret()
def test_compile_method():
- # py.test.skip("Not working yet.")
+ py.test.skip("Not working yet.")
sourcecode = """fib
^self < 2
ifTrue: [ 1 ]
Modified: pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/test/test_primitives.py
==============================================================================
--- pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/test/test_primitives.py (original)
+++ pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/test/test_primitives.py Fri Feb 22 04:28:42 2008
@@ -11,7 +11,7 @@
class MockFrame(model.W_MethodContext):
def __init__(self, stack):
- self.stack = stack
+ self._stack = stack
def wrap(x):
if isinstance(x, int): return utility.wrap_int(x)
@@ -32,17 +32,17 @@
interp, argument_count = mock(stack)
prim_table[code](interp, argument_count-1)
res = interp.s_active_context.pop()
- assert not len(interp.s_active_context.stack) # check args are consumed
+ assert not len(interp.s_active_context.stack()) # check args are consumed
return res
def prim_fails(code, stack):
interp, argument_count = mock(stack)
- orig_stack = list(interp.s_active_context.stack)
+ orig_stack = list(interp.s_active_context.stack())
try:
prim_table[code](interp, argument_count-1)
py.test.fail("Expected PrimitiveFailedError")
except PrimitiveFailedError:
- assert interp.s_active_context.stack == orig_stack
+ assert interp.s_active_context.stack() == orig_stack
# smallinteger tests
def test_small_int_add():
Modified: pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/test/test_shadow.py
==============================================================================
--- pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/test/test_shadow.py (original)
+++ pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/test/test_shadow.py Fri Feb 22 04:28:42 2008
@@ -88,7 +88,7 @@
def methodcontext(w_sender=objtable.w_nil, pc=1, stackpointer=0, stacksize=5,
method=method()):
- stackstart = method.argsize + method.tempsize + 7
+ stackstart = 7 # (len notation, not idx notation)
w_object = model.W_PointersObject(classtable.w_MethodContext, stackstart+stacksize)
w_object.store(constants.CTXPART_SENDER_INDEX, w_sender)
w_object.store(constants.CTXPART_PC_INDEX, utility.wrap_int(pc))
More information about the Pypy-commit
mailing list