<s> from pypy . objspace . flow . model import traverse , Block , Link , Variable , Constant <EOL> from pypy . translator . backendopt . tailrecursion import remove_tail_calls_to_self <EOL> from pypy . translator . translator import TranslationContext , graphof <EOL> from pypy . rpython . llinterp import LLInterpreter <EOL> from pypy . translator . test . snippet import is_perfect_number <EOL> def test_recursive_gcd ( ) : <EOL> def gcd ( a , b ) : <EOL> if a == <NUM_LIT:1> or a == <NUM_LIT:0> : <EOL> return b <EOL> if a > b : <EOL> return gcd ( b , a ) <EOL> return gcd ( b % a , a ) <EOL> t = TranslationContext ( ) <EOL> t . buildannotator ( ) . build_types ( gcd , [ int , int ] ) <EOL> t . buildrtyper ( ) . specialize ( ) <EOL> gcd_graph = graphof ( t , gcd ) <EOL> remove_tail_calls_to_self ( t , gcd_graph ) <EOL> lli = LLInterpreter ( t . rtyper ) <EOL> res = lli . eval_graph ( gcd_graph , ( <NUM_LIT:15> , <NUM_LIT> ) ) <EOL> assert res == <NUM_LIT:5> </s>
