Author: Anton Gulenko <anton.gule...@googlemail.com> Branch: storage-context-state-v2 Changeset: r953:6a476300d0c3 Date: 2014-07-18 15:29 +0200 http://bitbucket.org/pypy/lang-smalltalk/changeset/6a476300d0c3/
Log: Fixed tests, added tests. 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 @@ -978,9 +978,32 @@ 2, "value:value:"]], test) -def test_c_stack_reset_on_sender_chain_manipulation(): - bytes = reduce(operator.add, map(chr, [0x84, 0xc0, 0x00])) +def test_frame_dirty_if_active(): + bytes = reduce(operator.add, map(chr, [0x84, 0xc0, 0x00])) + returnReceiverBytecode w_frame, s_frame = new_frame(bytes) s_frame.store_w_receiver(w_frame) s_frame.push(w_frame) - py.test.raises(interpreter.SenderChainManipulation, step_in_interp, s_frame) + s_frame.state = shadow.ActiveContext + step_in_interp(s_frame) + assert s_frame.state is shadow.DirtyContext + +def test_frame_not_dirty_if_inactive(): + bytes = reduce(operator.add, map(chr, [0x84, 0xc0, 0x00])) + returnReceiverBytecode + w_frame, s_frame = new_frame(bytes) + w_other_frame, s_other_frame = new_frame("") + s_frame.store_w_receiver(w_other_frame) + s_frame.push(w_frame) + s_frame.state = shadow.ActiveContext + step_in_interp(s_frame) + assert s_frame.state is shadow.ActiveContext + assert s_other_frame.state is shadow.InactiveContext + +def test_raise_SenderManipulation_on_dirty_frame(): + w_frame, s_frame = new_frame(returnReceiverBytecode) + s_frame.state = shadow.DirtyContext + def run_frame(): + #import pdb; pdb.set_trace() + interp._loop = True + interp.stack_frame(s_frame, None) + py.test.raises(interpreter.SenderChainManipulation, run_frame) + \ No newline at end of file diff --git a/spyvm/test/test_zin_squeak_4_5_image.py b/spyvm/test/test_zin_squeak_4_5_image.py --- a/spyvm/test/test_zin_squeak_4_5_image.py +++ b/spyvm/test/test_zin_squeak_4_5_image.py @@ -43,7 +43,7 @@ # create a frame for our newly crafted method with a valid sender (to avoid raising returnFromTop to early) s_initial_frame = create_method(chr(0x7c)).create_frame(space, w(0), []) s_frame = w_method.create_frame(space, w(0)) - s_frame.store_s_sender(s_initial_frame, raise_error=False) + s_frame.store_s_sender(s_initial_frame) try: interp.loop(s_frame.w_self()) @@ -70,7 +70,7 @@ # create a frame for our newly crafted method with a valid sender (to avoid raising returnFromTop to early) s_initial_frame = create_method(chr(0x7c)).create_frame(space, w(0)) s_frame = w_method.create_frame(space, w(0)) - s_frame.store_s_sender(s_initial_frame, raise_error=False) + s_frame.store_s_sender(s_initial_frame) try: interp.loop(s_frame.w_self()) diff --git a/spyvm/test/util.py b/spyvm/test/util.py --- a/spyvm/test/util.py +++ b/spyvm/test/util.py @@ -85,7 +85,7 @@ if not self._loop: # this test is done to not loop in test, but rather step just once where wanted # Unfortunately, we have to mimick some of the original behaviour. - s_new_frame.store_s_sender(s_sender, raise_error=False) + s_new_frame.store_s_sender(s_sender) return s_new_frame return interpreter.Interpreter.stack_frame(self, s_new_frame, s_sender, may_context_switch) _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit