<s> """<STR_LIT>""" <EOL> from pypy . rlib . nonconst import NonConstant <EOL> from pypy . objspace . flow . objspace import FlowObjSpace <EOL> from pypy . annotation . annrpython import RPythonAnnotator <EOL> from pypy . conftest import option <EOL> from pypy . annotation . model import SomeInstance <EOL> def test_nonconst ( ) : <EOL> def nonconst_f ( ) : <EOL> a = NonConstant ( <NUM_LIT:3> ) <EOL> return a <EOL> a = RPythonAnnotator ( ) <EOL> s = a . build_types ( nonconst_f , [ ] ) <EOL> assert s . knowntype is int <EOL> assert not hasattr ( s , '<STR_LIT>' ) <EOL> def test_nonconst_list ( ) : <EOL> def nonconst_l ( ) : <EOL> a = NonConstant ( [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] ) <EOL> return a [ <NUM_LIT:0> ] <EOL> a = RPythonAnnotator ( ) <EOL> s = a . build_types ( nonconst_l , [ ] ) <EOL> assert s . knowntype is int <EOL> assert not hasattr ( s , '<STR_LIT>' ) <EOL> def test_nonconst_instance ( ) : <EOL> class A : <EOL> pass <EOL> a = A ( ) <EOL> def nonconst_i ( ) : <EOL> return NonConstant ( a ) <EOL> a = RPythonAnnotator ( ) <EOL> s = a . build_types ( nonconst_i , [ ] ) <EOL> rtyper = a . translator . buildrtyper ( type_system = "<STR_LIT>" ) <EOL> rtyper . specialize ( ) <EOL> if option . view : <EOL> a . translator . view ( ) <EOL> assert isinstance ( s , SomeInstance ) <EOL> def test_bool_nonconst ( ) : <EOL> def fn ( ) : <EOL> return bool ( NonConstant ( False ) ) <EOL> assert not fn ( ) <EOL> a = RPythonAnnotator ( ) <EOL> s = a . build_types ( fn , [ ] ) <EOL> assert s . knowntype is bool <EOL> assert not hasattr ( s , '<STR_LIT>' ) <EOL> rtyper = a . translator . buildrtyper ( type_system = "<STR_LIT>" ) <EOL> rtyper . specialize ( ) <EOL> if option . view : <EOL> a . translator . view ( ) </s>
