<s> import py <EOL> from pypy . rpython . test . tool import BaseRtypingTest , LLRtypeMixin , OORtypeMixin <EOL> class BaseTestRemptydict ( BaseRtypingTest ) : <EOL> def test_empty_dict ( self ) : <EOL> class A : <EOL> pass <EOL> a = A ( ) <EOL> a . d1 = { } <EOL> def func ( ) : <EOL> a . d2 = { } <EOL> return bool ( a . d1 ) or bool ( a . d2 ) <EOL> res = self . interpret ( func , [ ] ) <EOL> assert res is False <EOL> def test_iterate_over_empty_dict ( self ) : <EOL> def f ( ) : <EOL> n = <NUM_LIT:0> <EOL> d = { } <EOL> for x in [ ] : n += x <EOL> for y in d : n += y <EOL> for z in d . iterkeys ( ) : n += z <EOL> for s in d . itervalues ( ) : n += s <EOL> for t , u in d . items ( ) : n += t * u <EOL> for t , u in d . iteritems ( ) : n += t * u <EOL> return n <EOL> res = self . interpret ( f , [ ] ) <EOL> assert res == <NUM_LIT:0> <EOL> class TestLLtype ( BaseTestRemptydict , LLRtypeMixin ) : <EOL> pass <EOL> class TestOOtype ( BaseTestRemptydict , OORtypeMixin ) : <EOL> def test_almost_empty_dict ( self ) : <EOL> def f ( flag ) : <EOL> d = { } <EOL> if flag : <EOL> d [ None ] = None <EOL> return None in d <EOL> assert self . interpret ( f , [ True ] ) is True <EOL> assert self . interpret ( f , [ False ] ) is False </s>
