Skip to content

Commit

Permalink
fix perform when additional arguments are passed and add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
timfel committed May 11, 2016
1 parent 43fbf2b commit 352bdf8
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
5 changes: 2 additions & 3 deletions rsqueakvm/primitives/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,10 +258,9 @@ def func(interp, s_frame, argcount):
arguments_w = s_frame.pop_and_return_n(argcount - 1)
w_selector = s_frame.pop()
w_rcvr = s_frame.top()
s_frame.push_all(arguments_w)
return s_frame._sendSelector(
w_selector, 0, interp, w_rcvr,
w_rcvr.class_shadow(interp.space))
w_selector, argcount - 1, interp, w_rcvr,
w_rcvr.class_shadow(interp.space), w_arguments=arguments_w)

@expose_primitive(PERFORM_WITH_ARGS,
unwrap_spec=[object, object, list],
Expand Down
30 changes: 30 additions & 0 deletions rsqueakvm/test/test_miniimage.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,39 @@ def test_primitive_perform():
for sel in selectors_w:
if sel.unwrap_string(None) == 'size':
w_sel = sel
break
size = _prim(space, PERFORM, [w_o, w_sel])
assert size.value == 3

def test_primitive_perform_with():
from rsqueakvm.test.test_primitives import _prim
w_o = space.wrap_list([space.wrap_int(1), 2, 3])
w_methoddict = w_o.class_shadow(space).s_superclass().s_superclass().s_superclass().s_superclass().w_methoddict()
w_methoddict.as_methoddict_get_shadow(space).sync_method_cache()
selectors_w = w_methoddict.strategy.methoddict.keys()
w_sel = None
for sel in selectors_w:
if sel.unwrap_string(None) == 'at:':
w_sel = sel
break
index = _prim(space, PERFORM, [w_o, w_sel, space.wrap_int(1)])
assert index.value == 1

def test_primitive_perform_with_with():
from rsqueakvm.test.test_primitives import _prim
w_o = space.wrap_list([1, 2, 3])
w_methoddict = w_o.class_shadow(space).s_superclass().s_superclass().s_superclass().s_superclass().w_methoddict()
w_methoddict.as_methoddict_get_shadow(space).sync_method_cache()
selectors_w = w_methoddict.strategy.methoddict.keys()
w_sel = None
for sel in selectors_w:
if sel.unwrap_string(None) == 'at:put:':
w_sel = sel
break
w_val = _prim(space, PERFORM, [w_o, w_sel, space.wrap_int(1), space.w_nil])
assert w_val is space.w_nil
assert w_o.fetch(space, 0) is space.w_nil

def test_primitive_perform_with_args():
from rsqueakvm.test.test_primitives import _prim
w_o = space.wrap_list([1, 2, 3])
Expand Down

0 comments on commit 352bdf8

Please sign in to comment.