#NEWLINE# def test_rewrite( ) : #NEWLINE# #INDENT# term = ( sum , [ ( add , 1 , 1 ) , ( add , 1 , 1 ) , ( add , 1 , 1 ) ] ) #NEWLINE# new_term = rs . rewrite ( term ) #NEWLINE# assert ( new_term == ( add , ( add , ( inc , 1 ) , ( inc , 1 ) ) , ( inc , 1 ) ) ) #NEWLINE# new_term = rs . rewrite ( new_term ) #NEWLINE# assert ( new_term == ( add , ( add , ( double , 1 ) , 2 ) , ( inc , 1 ) ) ) #NEWLINE# term = ( add , ( add , ( add , ( add , 1 , 2 ) , ( add , 1 , 2 ) ) , ( add , ( add , 1 , 2 ) , ( add , 1 , 2 ) ) ) , 1 ) #NEWLINE# assert ( rs . rewrite ( term ) == ( inc , ( double , ( double , ( add , 1 , 2 ) ) ) ) ) #NEWLINE# term = ( list , [ 1 , 2 , 3 ] ) #NEWLINE# assert ( rs . rewrite ( new_term ) == [ 1 , 2 , 3 ] ) #NEWLINE# term = ( list , ( map , inc , [ 1 , 2 , 3 ] ) ) #NEWLINE# assert ( rs . rewrite ( term ) == term )