#NEWLINE# def test_complicated_codegen( ) : #NEWLINE# #INDENT# from sympy import sin , cos , tan #NEWLINE# ( x , y , z ) = symbols ( 'x,y,z' ) #NEWLINE# name_expr = [ ( 'test1' , ( ( ( sin ( x ) + cos ( y ) ) + tan ( z ) ) ** 7 ) . expand ( ) ) , ( 'test2' , cos ( cos ( cos ( cos ( cos ( cos ( cos ( cos ( ( ( result + y ) + z ) ) ) ) ) ) ) ) ) ) ] #NEWLINE# result = codegen ( name_expr , 'C' , 'file' , header = False , empty = False ) #NEWLINE# assert ( result [ 0 ] [ 0 ] == 'file.c' ) #NEWLINE# assert ( result [ 0 ] [ 1 ] == '#include "file.h"\n#include <math.h>\ndouble test1(double x, double y, double z) {\n   double test1_result;\n   test1_result = pow(sin(x), 7) + 7*pow(sin(x), 6)*cos(y) + 7*pow(sin(x), 6)*tan(z) + 21*pow(sin(x), 5)*pow(cos(y), 2) + 42*pow(sin(x), 5)*cos(y)*tan(z) + 21*pow(sin(x), 5)*pow(tan(z), 2) + 35*pow(sin(x), 4)*pow(cos(y), 3) + 105*pow(sin(x), 4)*pow(cos(y), 2)*tan(z) + 105*pow(sin(x), 4)*cos(y)*pow(tan(z), 2) + 35*pow(sin(x), 4)*pow(tan(z), 3) + 35*pow(sin(x), 3)*pow(cos(y), 4) + 140*pow(sin(x), 3)*pow(cos(y), 3)*tan(z) + 210*pow(sin(x), 3)*pow(cos(y), 2)*pow(tan(z), 2) + 140*pow(sin(x), 3)*cos(y)*pow(tan(z), 3) + 35*pow(sin(x), 3)*pow(tan(z), 4) + 21*pow(sin(x), 2)*pow(cos(y), 5) + 105*pow(sin(x), 2)*pow(cos(y), 4)*tan(z) + 210*pow(sin(x), 2)*pow(cos(y), 3)*pow(tan(z), 2) + 210*pow(sin(x), 2)*pow(cos(y), 2)*pow(tan(z), 3) + 105*pow(sin(x), 2)*cos(y)*pow(tan(z), 4) + 21*pow(sin(x), 2)*pow(tan(z), 5) + 7*sin(x)*pow(cos(y), 6) + 42*sin(x)*pow(cos(y), 5)*tan(z) + 105*sin(x)*pow(cos(y), 4)*pow(tan(z), 2) + 140*sin(x)*pow(cos(y), 3)*pow(tan(z), 3) + 105*sin(x)*pow(cos(y), 2)*pow(tan(z), 4) + 42*sin(x)*cos(y)*pow(tan(z), 5) + 7*sin(x)*pow(tan(z), 6) + pow(cos(y), 7) + 7*pow(cos(y), 6)*tan(z) + 21*pow(cos(y), 5)*pow(tan(z), 2) + 35*pow(cos(y), 4)*pow(tan(z), 3) + 35*pow(cos(y), 3)*pow(tan(z), 4) + 21*pow(cos(y), 2)*pow(tan(z), 5) + 7*cos(y)*pow(tan(z), 6) + pow(tan(z), 7);\n   return test1_result;\n}\ndouble test2(double x, double y, double z) {\n   double test2_result;\n   test2_result = cos(cos(cos(cos(cos(cos(cos(cos(x + y + z))))))));\n   return test2_result;\n}\n' ) #NEWLINE# assert ( result [ 1 ] [ 0 ] == 'file.h' ) #NEWLINE# assert ( result [ 1 ] [ 1 ] == '#ifndef PROJECT__FILE__H\n#define PROJECT__FILE__H\ndouble test1(double x, double y, double z);\ndouble test2(double x, double y, double z);\n#endif\n' )