<s> from pypy . rpython . lltypesystem . lltype import * <EOL> from pypy . rpython . test . test_llinterp import interpret <EOL> def test_simple ( ) : <EOL> def fn ( obj ) : <EOL> return obj + <NUM_LIT:1> <EOL> _1L = pyobjectptr ( <NUM_LIT:1> L ) <EOL> res = interpret ( fn , [ _1L ] , someobjects = True ) <EOL> assert res . _obj . value == <NUM_LIT:2> L <EOL> def test_obj_obj_dict ( ) : <EOL> def f ( i , c ) : <EOL> d = { } <EOL> d [ <NUM_LIT:1> ] = '<STR_LIT:a>' <EOL> d [ '<STR_LIT:a>' ] = i <EOL> d [ '<STR_LIT>' ] = c <EOL> d [ i ] = c <EOL> return len ( d ) <EOL> res = interpret ( f , [ <NUM_LIT:2> , '<STR_LIT:c>' ] , someobjects = True ) <EOL> assert res == <NUM_LIT:4> <EOL> res = interpret ( f , [ <NUM_LIT:3> , '<STR_LIT:c>' ] , someobjects = True ) <EOL> assert res == <NUM_LIT:4> <EOL> def test_obj_list ( ) : <EOL> def f ( i , c ) : <EOL> lis = [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> ] <EOL> lis [ i ] = c <EOL> lis . append ( i ) <EOL> return len ( lis ) <EOL> res = interpret ( f , [ <NUM_LIT:2> , '<STR_LIT:c>' ] , someobjects = True ) <EOL> assert res == <NUM_LIT:5> <EOL> res = interpret ( f , [ <NUM_LIT:3> , '<STR_LIT:c>' ] , someobjects = True ) <EOL> assert res == <NUM_LIT:5> <EOL> def test_obj_iter ( ) : <EOL> def f ( flag ) : <EOL> if flag : <EOL> x = ( <NUM_LIT:1> , <NUM_LIT:2> ) <EOL> else : <EOL> x = '<STR_LIT>' <EOL> lst = [ u for u in x ] <EOL> return lst [ flag ] <EOL> res = interpret ( f , [ <NUM_LIT:1> ] , someobjects = True ) <EOL> assert res . _obj . value == <NUM_LIT:2> <EOL> res = interpret ( f , [ <NUM_LIT:0> ] , someobjects = True ) <EOL> assert res . _obj . value == '<STR_LIT:3>' <EOL> def test_listofobj_iter ( ) : <EOL> def f ( look ) : <EOL> lst = [ '<STR_LIT:*>' , <NUM_LIT:2> , <NUM_LIT:5> ] <EOL> for u in lst : <EOL> if u == look : <EOL> return True <EOL> return False <EOL> res = interpret ( f , [ <NUM_LIT:1> ] , someobjects = True ) <EOL> assert res is False <EOL> res = interpret ( f , [ <NUM_LIT:2> ] , someobjects = True ) <EOL> assert res is True </s>
