<s> from pypy . conftest import gettestobjspace <EOL> from py . test import skip <EOL> class BaseAppTestPicklePrerequisites ( object ) : <EOL> OPTIONS = { } <EOL> def setup_class ( cls ) : <EOL> space = gettestobjspace ( usemodules = ( '<STR_LIT>' , ) , ** cls . OPTIONS ) <EOL> cls . space = space <EOL> def test_pickle_switch_function ( object ) : <EOL> import _stackless , pickle <EOL> sw = _stackless . coroutine . switch . im_func <EOL> dump = pickle . dumps ( sw ) <EOL> res = pickle . loads ( dump ) <EOL> assert res is sw <EOL> assert res . func_code is sw . func_code <EOL> assert res . func_doc is sw . func_doc <EOL> assert res . func_globals is sw . func_globals <EOL> def test_pickle_switch_function_code ( object ) : <EOL> import _stackless , pickle <EOL> sw = _stackless . coroutine . switch . im_func . func_code <EOL> dump = pickle . dumps ( sw ) <EOL> res = pickle . loads ( dump ) <EOL> assert res is sw <EOL> class AppTestPicklePrerequisites ( BaseAppTestPicklePrerequisites ) : <EOL> pass <EOL> class AppTestPicklePrerequisitesBuiltinShortcut ( BaseAppTestPicklePrerequisites ) : <EOL> OPTIONS = { "<STR_LIT>" : True } <EOL> class FrameCheck ( object ) : <EOL> def __init__ ( self , name ) : <EOL> self . name = name <EOL> def __eq__ ( self , frame ) : <EOL> return frame . pycode . co_name == self . name <EOL> class BytecodeCheck ( object ) : <EOL> def __init__ ( self , code , op , arg ) : <EOL> self . code = code <EOL> self . op = chr ( op ) + chr ( arg & <NUM_LIT> ) + chr ( arg >> <NUM_LIT:8> & <NUM_LIT> ) <EOL> def __eq__ ( self , pos ) : <EOL> return self . code [ pos - <NUM_LIT:3> : pos ] == self . op <EOL> class BaseTestReconstructFrameChain ( object ) : <EOL> OPTIONS = { } <EOL> def setup_class ( cls ) : <EOL> space = gettestobjspace ( usemodules = ( '<STR_LIT>' , ) , ** cls . OPTIONS ) <EOL> cls . space = space <EOL> from pypy . rlib import rstack <EOL> cls . old_resume_state_create = rstack . resume_state_create <EOL> def tr ( prevstate , label , * args ) : <EOL> if prevstate is None : <EOL> prevstate = [ ] <EOL> return prevstate + [ ( label , args ) ] <EOL> rstack . resume_state_create = tr <EOL> w_opmap = space . appexec ( [ ] , """<STR_LIT>""" ) <EOL> opmap = space . unwrap ( w_opmap ) <EOL> cls . CALL_FUNCTION = opmap [ '<STR_LIT>' ] <EOL> cls . CALL_FUNCTION_VAR = opmap [ '<STR_LIT>' ] <EOL> cls . CALL_METHOD = opmap [ '<STR_LIT>' ] <EOL> cls . callmethod = getattr ( cls , cls . callmethod_label ) <EOL> def teardown_class ( cls ) : <EOL> from pypy . rlib import rstack <EOL> rstack . resume_state_create = cls . old_resume_state_create <EOL> def start ( self , w_coro ) : <EOL> self . i = <NUM_LIT:0> <EOL> self . frame_to_check = w_coro . frame <EOL> w_coro . frame = None <EOL> def end ( self ) : <EOL> assert self . i == len ( self . frame_to_check ) <EOL> def check_entry ( self , label , * args ) : <EOL> frame = self . frame_to_check <EOL> assert frame [ self . i ] == ( label , args ) <EOL> self . i += <NUM_LIT:1> <EOL> def test_two_frames_simple ( self ) : <EOL> space = self . space <EOL> w_res = space . appexec ( [ ] , """<STR_LIT>""" ) <EOL> w_co , w_f , w_g = space . viewiterable ( w_res ) <EOL> ec = space . getexecutioncontext ( ) <EOL> fcode = w_f . code . co_code <EOL> gcode = w_g . code . co_code <EOL> self . start ( w_co ) <EOL> e = self . check_entry <EOL> e ( '<STR_LIT>' ) <EOL> e ( '<STR_LIT>' , w_co . costate ) <EOL> e ( '<STR_LIT>' , w_co . costate ) <EOL> e ( '<STR_LIT>' , FrameCheck ( '<STR_LIT:f>' ) , ec ) <EOL> e ( '<STR_LIT>' , FrameCheck ( '<STR_LIT:f>' ) , fcode , ec ) <EOL> e ( '<STR_LIT>' , FrameCheck ( '<STR_LIT:f>' ) , fcode , ec ) <EOL> e ( '<STR_LIT>' , FrameCheck ( '<STR_LIT:f>' ) , fcode , <EOL> BytecodeCheck ( fcode , self . CALL_FUNCTION , <NUM_LIT:1> ) , ec ) <EOL> e ( '<STR_LIT>' , FrameCheck ( '<STR_LIT:f>' ) , <NUM_LIT:1> ) <EOL> e ( '<STR_LIT>' , FrameCheck ( '<STR_LIT:g>' ) , ec ) <EOL> e ( '<STR_LIT>' , FrameCheck ( '<STR_LIT:g>' ) , gcode , ec ) <EOL> e ( '<STR_LIT>' , FrameCheck ( '<STR_LIT:g>' ) , gcode , ec ) <EOL> e ( '<STR_LIT>' , FrameCheck ( '<STR_LIT:g>' ) , gcode , <EOL> BytecodeCheck ( gcode , self . callmethod , <NUM_LIT:0> ) , ec ) <EOL> e ( self . callmethod_label , FrameCheck ( '<STR_LIT:g>' ) , <NUM_LIT:0> ) <EOL> e ( '<STR_LIT>' , w_co . costate , space ) <EOL> e ( '<STR_LIT>' , w_co . costate ) <EOL> self . end ( ) <EOL> def test_two_frames_stararg ( self ) : <EOL> space = self . space <EOL> w_res = space . appexec ( [ ] , """<STR_LIT>""" ) <EOL> w_co , w_f , w_g = space . viewiterable ( w_res ) <EOL> ec = space . getexecutioncontext ( ) <EOL> fcode = w_f . code . co_code <EOL> gcode = w_g . code . co_code <EOL> self . start ( w_co ) <EOL> e = self . check_entry <EOL> e ( '<STR_LIT>' ) <EOL> e ( '<STR_LIT>' , w_co . costate ) <EOL> e ( '<STR_LIT>' , w_co . costate ) <EOL> e ( '<STR_LIT>' , FrameCheck ( '<STR_LIT:f>' ) , ec ) <EOL> e ( '<STR_LIT>' , FrameCheck ( '<STR_LIT:f>' ) , fcode , ec ) <EOL> e ( '<STR_LIT>' , FrameCheck ( '<STR_LIT:f>' ) , fcode , ec ) <EOL> e ( '<STR_LIT>' , FrameCheck ( '<STR_LIT:f>' ) , fcode , <EOL> BytecodeCheck ( fcode , self . CALL_FUNCTION_VAR , <NUM_LIT:2> + ( <NUM_LIT:1> << <NUM_LIT:8> ) ) , ec ) <EOL> e ( '<STR_LIT>' , FrameCheck ( '<STR_LIT:f>' ) ) <EOL> e ( '<STR_LIT>' , FrameCheck ( '<STR_LIT:g>' ) , ec ) <EOL> e ( '<STR_LIT>' , FrameCheck ( '<STR_LIT:g>' ) , gcode , ec ) <EOL> e ( '<STR_LIT>' , FrameCheck ( '<STR_LIT:g>' ) , gcode , ec ) <EOL> e ( '<STR_LIT>' , FrameCheck ( '<STR_LIT:g>' ) , gcode , <EOL> BytecodeCheck ( gcode , self . callmethod , <NUM_LIT:0> ) , ec ) <EOL> e ( self . callmethod_label , FrameCheck ( '<STR_LIT:g>' ) , <NUM_LIT:0> ) <EOL> e ( '<STR_LIT>' , w_co . costate , space ) <EOL> e ( '<STR_LIT>' , w_co . costate ) <EOL> self . end ( ) <EOL> def test_two_frames_method ( self ) : <EOL> space = self . space <EOL> w_res = space . appexec ( [ ] , """<STR_LIT>""" ) <EOL> w_co , w_f , w_g = space . viewiterable ( w_res ) <EOL> ec = space . getexecutioncontext ( ) <EOL> fcode = w_f . code . co_code <EOL> gcode = w_g . code . co_code <EOL> self . start ( w_co ) <EOL> e = self . check_entry <EOL> e ( '<STR_LIT>' ) <EOL> e ( '<STR_LIT>' , w_co . costate ) <EOL> e ( '<STR_LIT>' , w_co . costate ) <EOL> e ( '<STR_LIT>' , FrameCheck ( '<STR_LIT:f>' ) , ec ) <EOL> e ( '<STR_LIT>' , FrameCheck ( '<STR_LIT:f>' ) , fcode , ec ) <EOL> e ( '<STR_LIT>' , FrameCheck ( '<STR_LIT:f>' ) , fcode , ec ) <EOL> e ( '<STR_LIT>' , FrameCheck ( '<STR_LIT:f>' ) , fcode , <EOL> BytecodeCheck ( fcode , self . callmethod , <NUM_LIT:1> ) , ec ) <EOL> e ( self . callmethod_label , FrameCheck ( '<STR_LIT:f>' ) , <NUM_LIT:1> ) <EOL> e ( '<STR_LIT>' , FrameCheck ( '<STR_LIT:g>' ) , ec ) <EOL> e ( '<STR_LIT>' , FrameCheck ( '<STR_LIT:g>' ) , gcode , ec ) <EOL> e ( '<STR_LIT>' , FrameCheck ( '<STR_LIT:g>' ) , gcode , ec ) <EOL> e ( '<STR_LIT>' , FrameCheck ( '<STR_LIT:g>' ) , gcode , <EOL> BytecodeCheck ( gcode , self . callmethod , <NUM_LIT:0> ) , ec ) <EOL> e ( self . callmethod_label , FrameCheck ( '<STR_LIT:g>' ) , <NUM_LIT:0> ) <EOL> e ( '<STR_LIT>' , w_co . costate , space ) <EOL> e ( '<STR_LIT>' , w_co . costate ) <EOL> self . end ( ) <EOL> class TestReconstructFrameChain ( BaseTestReconstructFrameChain ) : <EOL> callmethod_label = '<STR_LIT>' <EOL> class TestReconstructFrameChain_CALL_METHOD ( BaseTestReconstructFrameChain ) : <EOL> OPTIONS = { "<STR_LIT>" : True , <EOL> } <EOL> callmethod_label = '<STR_LIT>' </s>
