<s> import py <EOL> from pypy . rpython . test . test_llinterp import interpret <EOL> from pypy . rpython . ootypesystem . ootype import Signed , Float , Dict , new , typeOf , setDictTypes <EOL> def test_new ( ) : <EOL> DT = Dict ( Signed , Float ) <EOL> d = new ( DT ) <EOL> assert typeOf ( d ) == DT <EOL> def test_length ( ) : <EOL> DT = Dict ( Signed , Float ) <EOL> d = new ( DT ) <EOL> d . ll_set ( <NUM_LIT> , <NUM_LIT> ) <EOL> assert d . ll_length ( ) == <NUM_LIT:1> <EOL> def test_setitem_getitem ( ) : <EOL> DT = Dict ( Signed , Float ) <EOL> d = new ( DT ) <EOL> d . ll_set ( <NUM_LIT> , <NUM_LIT> ) <EOL> assert d . ll_contains ( <NUM_LIT> ) <EOL> assert d . ll_get ( <NUM_LIT> ) == <NUM_LIT> <EOL> def test_iteritems ( ) : <EOL> DT = Dict ( Signed , Float ) <EOL> d = new ( DT ) <EOL> d . ll_set ( <NUM_LIT> , <NUM_LIT> ) <EOL> d . ll_set ( <NUM_LIT> , <NUM_LIT> ) <EOL> it = d . ll_get_items_iterator ( ) <EOL> items = [ ] <EOL> while it . ll_go_next ( ) : <EOL> items . append ( ( it . ll_current_key ( ) , it . ll_current_value ( ) ) ) <EOL> items . sort ( ) <EOL> assert items == [ ( <NUM_LIT> , <NUM_LIT> ) , ( <NUM_LIT> , <NUM_LIT> ) ] <EOL> def test_optional_types ( ) : <EOL> DT = Dict ( ) <EOL> DT2 = Dict ( Signed , Float ) <EOL> assert DT != Signed <EOL> assert DT != DT2 <EOL> assert DT2 != DT <EOL> py . test . raises ( TypeError , hash , DT ) <EOL> setDictTypes ( DT , Signed , Float ) <EOL> assert DT == DT2 <EOL> assert DT2 == DT <EOL> assert hash ( DT ) == hash ( DT2 ) <EOL> def test_recursive_str_hash ( ) : <EOL> DT = Dict ( ) <EOL> setDictTypes ( DT , Signed , DT ) <EOL> assert isinstance ( str ( DT ) , str ) <EOL> assert isinstance ( hash ( DT ) , int ) <EOL> def test_invalid_cache ( ) : <EOL> DT = Dict ( Signed , Signed ) <EOL> d = new ( DT ) <EOL> py . test . raises ( AssertionError , d . ll_get , <NUM_LIT:0> ) <EOL> d . ll_set ( <NUM_LIT> , <NUM_LIT:1> ) <EOL> d . ll_contains ( <NUM_LIT> ) <EOL> py . test . raises ( AssertionError , d . ll_get , <NUM_LIT> ) </s>
