<s> from pypy . rpython . test . tool import BaseRtypingTest , LLRtypeMixin , OORtypeMixin <EOL> from pypy . rlib . rstruct . runpack import runpack <EOL> import struct <EOL> class BaseTestRStruct ( BaseRtypingTest ) : <EOL> def test_unpack ( self ) : <EOL> def fn ( ) : <EOL> return runpack ( '<STR_LIT>' , '<STR_LIT>' ) [ <NUM_LIT:1> ] <EOL> assert fn ( ) == <NUM_LIT:3> <EOL> assert self . interpret ( fn , [ ] ) == <NUM_LIT:3> <EOL> def test_unpack_2 ( self ) : <EOL> data = struct . pack ( '<STR_LIT>' , <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:4> ) <EOL> def fn ( ) : <EOL> a , b , c , d = runpack ( '<STR_LIT>' , data ) <EOL> return a * <NUM_LIT:1000> + b * <NUM_LIT:100> + c * <NUM_LIT:10> + d <EOL> assert fn ( ) == <NUM_LIT> <EOL> assert self . interpret ( fn , [ ] ) == <NUM_LIT> <EOL> def test_unpack_single ( self ) : <EOL> data = struct . pack ( '<STR_LIT:i>' , <NUM_LIT> ) <EOL> def fn ( ) : <EOL> return runpack ( '<STR_LIT:i>' , data ) <EOL> assert fn ( ) == <NUM_LIT> <EOL> assert self . interpret ( fn , [ ] ) == <NUM_LIT> <EOL> class TestLLType ( BaseTestRStruct , LLRtypeMixin ) : <EOL> pass <EOL> class TestOOType ( BaseTestRStruct , OORtypeMixin ) : <EOL> pass </s>
