polserver/testsuite/escript/math/math0007.src
turleypol 4782dc9757
removed unused code from old compiler out of EProgram (#750)
increased testcoverage for math module to almost 100%
2025-01-23 19:53:11 +01:00

83 lines
2.1 KiB
Text

use math;
print( "sin" );
print( sin( "" ).?errortext );
print( sin( 0 ) == 0 );
print( sin( constpi() / 2 ) == 1 );
print( "cos" );
print( cos( "" ).?errortext );
print( cos( 0 ) == 1 );
print( cos( constpi() / 2 ) == 0 );
print( "tan" );
print( tan( "" ).?errortext );
print( tan( 0 ) == 0 );
print( tan( constpi() / 4 ) == 1 );
print( "asin" );
print( asin( "" ).?errortext );
print( asin( 0 ) == 0 );
print( asin( 1 ) == constpi() / 2 );
print( "acos" );
print( acos( "" ).?errortext );
print( acos( 0 ) == constpi() / 2 );
print( acos( 1 ) == 0 );
print( "atan" );
print( atan( "" ).?errortext );
print( atan( 0 ) == 0 );
print( atan( 1 ) == constpi() / 4 );
print( "pow" );
print( pow( "", "" ).?errortext );
print( pow( 3, 2 ) == 9 );
print( pow( 5, 2 ) == 25 );
print( "sqrt" );
print( sqrt( "" ).?errortext );
print( sqrt( 9 ) == 3 );
print( sqrt( 25 ) == 5 );
print( "root" );
print( root( "", "" ).?errortext );
print( root( 27, 3 ) == 3 );
print( "min" );
print( min( "" ).?errortext );
print( min( {} ).?errortext );
print( min( { "" } ).?errortext );
print( min( 3, 1 ) == 1 );
print( min( 2.0, 3 ) == 2.0 );
print( min( { 5, 4, 1 } ) == 1 );
print( "max" );
print( max( "" ).?errortext );
print( max( {} ).?errortext );
print( max( { "" } ).?errortext );
print( max( 3, 1 ) == 3 );
print( max( 2.0, 3 ) == 3 );
print( max( { 5, 4, 7, 1 } ) == 7 );
print( "abs" );
print( abs( "" ).?errortext );
print( abs( -1 ) == 1 );
print( abs( -1.5 ) == 1.5 );
print( "log10" );
print( log10( "" ).?errortext );
print( log10( 10 ) == 1 );
print( log10( 100 ) == 2 );
print( "loge" );
print( loge( "" ).?errortext );
print( loge( pow( conste(), 2 ) ) == 2 );
print( "ceil" );
print( ceil( "" ).?errortext );
print( ceil( 1.5 ) == 2 );
print( "floor" );
print( floor( "" ).?errortext );
print( floor( 1.5 ) == 1 );
print( "radtodeg" );
print( radtodeg( "" ).?errortext );
print( radtodeg( 2 * constpi() ) == 360 );
print( radtodeg( constpi() ) == 180 );
print( "degtorad" );
print( degtorad( "" ).?errortext );
print( degtorad( 360 ) == 2 * constpi() );
print( degtorad( 180 ) == constpi() );