diff --git a/pub/CMakeLists.txt b/pub/CMakeLists.txt index 5e11277578e06baf87747815c53f080a89921fd1..4e8e7d5ae247ce61faeb992f4114e9af9bde5584 100644 --- a/pub/CMakeLists.txt +++ b/pub/CMakeLists.txt @@ -56,3 +56,4 @@ add_subdirectory(src) add_subdirectory(share) add_subdirectory(man) add_subdirectory(utest) +add_subdirectory(ftest) diff --git a/pub/ftest/CMakeLists.txt b/pub/ftest/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..1541e93978415d0683d37b15964bc7743e9d562a --- /dev/null +++ b/pub/ftest/CMakeLists.txt @@ -0,0 +1,18 @@ +# To run the tests on Linux, use 'make test' or 'ctest'. +# To select which tests to run, use 'ctest -R regex'. +# To see output from the individual tests, use 'ctest -V'. +# For more options, run 'ctest --help'. + +enable_testing() + +# We glob test sources, though this is often considered evil. +# Just touch CMakeLists.txt each time a test is added or withdrawn. + +file(GLOB test_sources "*.f2t") + +foreach(test_src ${test_sources}) + # remove directory path and suffix, to retain just the name of the test + string(REGEX REPLACE ".*/" "" test_name "${test_src}") + string(REGEX REPLACE ".f2t$" "" test_name "${test_name}") + add_test(${test_name} "${test_src}") +endforeach(test_src) diff --git a/pub/ftest/arithmetics.f2t b/pub/ftest/arithmetics.f2t index 6e050946b12f24f838934d767c583768260ec330..a18c73e66075a34680a75bcee11d560435653bf3 100755 --- a/pub/ftest/arithmetics.f2t +++ b/pub/ftest/arithmetics.f2t @@ -1,11 +1,11 @@ #!/usr/bin/env frida -throw_unless(2+3==5,"arithmetic_failure") -throw_unless(0.2+.3==.5,"arithmetic_failure") -throw_unless(0.2+3==3.2,"arithmetic_failure") -throw_unless(2<3,"arithmetic_failure") -throw_unless(!(3<3),"arithmetic_failure") -throw_unless(3<=3,"arithmetic_failure") -throw_unless(3.1>3,"arithmetic_failure") -throw_unless(!(3.>3),"arithmetic_failure") -throw_unless(!(-3.<-3),"arithmetic_failure") -exit(1) \ No newline at end of file +exit_unless(2+3==5,"arithmetic_failure") +exit_unless(0.2+.3==.5,"arithmetic_failure") +exit_unless(0.2+3==3.2,"arithmetic_failure") +exit_unless(2<3,"arithmetic_failure") +exit_unless(!(3<3),"arithmetic_failure") +exit_unless(3<=3,"arithmetic_failure") +exit_unless(3.1>3,"arithmetic_failure") +exit_unless(!(3.>3),"arithmetic_failure") +exit_unless(!(-3.<-3),"arithmetic_failure") +exit(0) \ No newline at end of file diff --git a/pub/ftest/curve_functionals.f2t b/pub/ftest/curve_functionals.f2t index 900ae2c6ac68eff02bebd983d349f8b1a296a445..c927989236213df954b93279bbc571a7d0879c0b 100755 --- a/pub/ftest/curve_functionals.f2t +++ b/pub/ftest/curve_functionals.f2t @@ -1,4 +1,4 @@ #!/usr/bin/env frida cca sin(t) -throw_unless(abs(integrate(0,pi)-2)<1e-14,"integration_failed") -exit(1) \ No newline at end of file +exit_unless(abs(integrate(0,pi)-2)<1e-14,"integration_failed") +exit(0) \ No newline at end of file diff --git a/pub/ftest/divisions.f2t b/pub/ftest/divisions.f2t index 6501107ab54e2a80640a73d9270fe8dfff1bc8a7..e2dd0893ea574f61beba887cdf5c80fa293371c7 100755 --- a/pub/ftest/divisions.f2t +++ b/pub/ftest/divisions.f2t @@ -1,5 +1,5 @@ #!/usr/bin/env frida -throw_unless(abs(5/3-5.0/3.0)<1e-14,"fp_division_failed") -throw_unless(5//3==1,"int_division_failed") -throw_unless(5%3==2,"modulo_failed") -exit(1) \ No newline at end of file +exit_unless(abs(5/3-5.0/3.0)<1e-14,"fp_division_failed") +exit_unless(5//3==1,"int_division_failed") +exit_unless(5%3==2,"modulo_failed") +exit(0) \ No newline at end of file diff --git a/pub/ftest/fit0.f2t b/pub/ftest/fit0.f2t index e64797a6dd6b288b263b37b8113101a1282bf26c..0ae27140d9a139fde29b13b06b6b3e9e714fdba6 100755 --- a/pub/ftest/fit0.f2t +++ b/pub/ftest/fit0.f2t @@ -5,6 +5,6 @@ oy! 7*i cc p0*t cwc cf -throw_unless(abs(p0-7)<1e-13,"fit_failed") -throw_unless(abs(f(1.5)-10.5)<1e-13,"curve_eval_failed") -exit(1) +exit_unless(abs(p0-7)<1e-13,"fit_failed") +exit_unless(abs(f(1.5)-10.5)<1e-13,"curve_eval_failed") +exit(0) diff --git a/pub/ftest/fit1.f2t b/pub/ftest/fit1.f2t index 92226a2349c83aa488a549aa45b31ba281f8323e..f160c8a43ccf127c7be077a279c7763b137b70f3 100755 --- a/pub/ftest/fit1.f2t +++ b/pub/ftest/fit1.f2t @@ -4,4 +4,4 @@ oy 100*(j+x^1.1) ody! sqrt(1+y) cc p0+p1*t cf -exit(1) +exit(0) diff --git a/pub/ftest/fit2glo.f2t b/pub/ftest/fit2glo.f2t index 39913b103e46954447e295b7a0c1e85b300aea49..bb3285c4ad749097ebb504c7695bf84e5d4b7f73 100755 --- a/pub/ftest/fit2glo.f2t +++ b/pub/ftest/fit2glo.f2t @@ -10,4 +10,4 @@ cp cg 1 cf cp -exit(1) +exit(0) diff --git a/pub/ftest/fit3resol.f2t b/pub/ftest/fit3resol.f2t index 4b859d6fc14e68055a36a9fa38306281188d092e..602a1d48e567195bd9c07589f6bce19c16b81cc9 100755 --- a/pub/ftest/fit3resol.f2t +++ b/pub/ftest/fit3resol.f2t @@ -5,4 +5,4 @@ fl dat-qel dat-res cp cf cp -exit(1) +exit(0) diff --git a/pub/ftest/fit4glofreez.f2t b/pub/ftest/fit4glofreez.f2t index f7e966f2b850b641d153354782b2a57f9012722c..d0bfe74c59ef6cb9e98b45ad4f64cc29c8a3b6f6 100755 --- a/pub/ftest/fit4glofreez.f2t +++ b/pub/ftest/fit4glofreez.f2t @@ -11,4 +11,4 @@ cg 1 m/ 0 cf cp -exit(1) +exit(0) diff --git a/pub/ftest/fit5restrict.f2t b/pub/ftest/fit5restrict.f2t index 5c17a53338c3e8c29f3d366409fcd6fd83470a87..938bb48ce8c201e547951e2a2ac0ff61f307b3b6 100755 --- a/pub/ftest/fit5restrict.f2t +++ b/pub/ftest/fit5restrict.f2t @@ -5,4 +5,4 @@ cc p0+p1*(t-p2) cwc cr y>.1 cf -exit(1) +exit(0) diff --git a/pub/ftest/fit6shift.f2t b/pub/ftest/fit6shift.f2t index 918e596cfdc7d72fe5978369af941b55c2eadc23..164e4617eb2f248fd474085f058d71013d5e1e72 100755 --- a/pub/ftest/fit6shift.f2t +++ b/pub/ftest/fit6shift.f2t @@ -11,6 +11,6 @@ op1 40 op2 1e-8 cv 2 cf -throw_unless(abs(p0[4,0]-.15)<.05,"shifted_resol_fit_failed") -throw_unless(abs(p1[4,0]-80)<1,"shifted_resol_fit_failed") -exit(1) +exit_unless(abs(p0[4,0]-.15)<.05,"shifted_resol_fit_failed") +exit_unless(abs(p1[4,0]-80)<1,"shifted_resol_fit_failed") +exit(0) diff --git a/pub/ftest/fj_c.f2t b/pub/ftest/fj_c.f2t index 637c6d1e67909cafb3039e6e4c9a342d2ad5a1dd..2ad11daaca5fd64bb5ef9d3e149493e11937025c 100755 --- a/pub/ftest/fj_c.f2t +++ b/pub/ftest/fj_c.f2t @@ -9,4 +9,4 @@ cwc cf 4:7 mfj cp -exit(1) +exit(0) diff --git a/pub/ftest/freeze.f2t b/pub/ftest/freeze.f2t index ac33b04dac801229ad11f112ef1bcbca964abf48..fc52fbe7016d68e6f2227d1022a529df3b6f2276 100755 --- a/pub/ftest/freeze.f2t +++ b/pub/ftest/freeze.f2t @@ -3,14 +3,14 @@ fm 1 1000 h oy! 1 m/ 33,100:300:10 oy! 0 -throw_unless(y[,32,0]==0,"failed") -throw_unless(y[,33,0]==1,"failed") -throw_unless(y[,100,0]==1,"failed") -throw_unless(y[,101,0]==0,"failed") +exit_unless(y[,32,0]==0,"failed") +exit_unless(y[,33,0]==1,"failed") +exit_unless(y[,100,0]==1,"failed") +exit_unless(y[,101,0]==0,"failed") m/- oy! 2 -throw_unless(y[,32,0]==2,"failed") -throw_unless(y[,33,0]==2,"failed") -throw_unless(y[,100,0]==2,"failed") -throw_unless(y[,101,0]==2,"failed") -exit(1) \ No newline at end of file +exit_unless(y[,32,0]==2,"failed") +exit_unless(y[,33,0]==2,"failed") +exit_unless(y[,100,0]==2,"failed") +exit_unless(y[,101,0]==2,"failed") +exit(0) \ No newline at end of file diff --git a/pub/ftest/i_as_j.f2t b/pub/ftest/i_as_j.f2t index 55de5f1ec447c9b5da1849617b044aa7a8ed1692..c2a09be611a974e6e527eca230b6e9420bcb3ba6 100755 --- a/pub/ftest/i_as_j.f2t +++ b/pub/ftest/i_as_j.f2t @@ -4,6 +4,6 @@ oy! 10*j+i oz0! 100*j 0 oi y[,,1] 1 oy z0[0,i] -throw_unless(x[2,0,1]==100,"x_wrong") -throw_unless(y[2,0,1]==100,"y_wrong") -exit(1) \ No newline at end of file +exit_unless(x[2,0,1]==100,"x_wrong") +exit_unless(y[2,0,1]==100,"y_wrong") +exit(0) \ No newline at end of file diff --git a/pub/ftest/jsel.f2t b/pub/ftest/jsel.f2t index 615bd8899de4c8df3a4e137cfef2afb116a75af6..62ab7f32ca462f86ca75e186e4960bd82eb9f06b 100755 --- a/pub/ftest/jsel.f2t +++ b/pub/ftest/jsel.f2t @@ -1,18 +1,18 @@ #!/usr/bin/env frida fm 1000 1 h -throw_unless(ni==1000,"mpr_failed") +exit_unless(ni==1000,"mpr_failed") mpr 0:899 -throw_unless(ni==900,"mpr_failed") +exit_unless(ni==900,"mpr_failed") mpr 50: -throw_unless(ni==850,"mpr_failed") +exit_unless(ni==850,"mpr_failed") mpr :799 -throw_unless(ni==800,"mpr_failed") +exit_unless(ni==800,"mpr_failed") mpr ::4 -throw_unless(ni==200,"mpr_failed") +exit_unless(ni==200,"mpr_failed") mpd ::4 -throw_unless(ni==150,"mpr_failed") +exit_unless(ni==150,"mpr_failed") mpr 0:119:3 -throw_unless(ni==40,"mpr_failed") +exit_unless(ni==40,"mpr_failed") mpd 0:39:4 -throw_unless(ni==30,"mpr_failed") -exit(1) \ No newline at end of file +exit_unless(ni==30,"mpr_failed") +exit(0) \ No newline at end of file diff --git a/pub/ftest/mpa.f2t b/pub/ftest/mpa.f2t index 14f7619bff6ed80980412e576c8f4f295d49db3c..f88813c16b3947cd2a82684e197e24782fa56fe8 100755 --- a/pub/ftest/mpa.f2t +++ b/pub/ftest/mpa.f2t @@ -2,14 +2,14 @@ fm 9 1 h 0 oy 3+i 1 mpa 0,3 -throw_unless(abs(y[2,0,0]-(3+1))<1e-15,"mpa_test11") -throw_unless(abs(y[2,0,1]-(3+5.5))<1e-15,"mpa_test12") +exit_unless(abs(y[2,0,0]-(3+1))<1e-15,"mpa_test11") +exit_unless(abs(y[2,0,1]-(3+5.5))<1e-15,"mpa_test12") 1 mpaf 3 -throw_unless(ni[3,0]==3,"mpa_test20") -throw_unless(abs(y[3,0,0]-(3+1))<1e-15,"mpa_test21") -throw_unless(abs(y[3,0,2]-(3+7))<1e-15,"mpa_test22") +exit_unless(ni[3,0]==3,"mpa_test20") +exit_unless(abs(y[3,0,0]-(3+1))<1e-15,"mpa_test21") +exit_unless(abs(y[3,0,2]-(3+7))<1e-15,"mpa_test22") 1 mpaf 4 -throw_unless(ni[4,0]==2,"mpa_test30") -throw_unless(abs(y[4,0,0]-(3+1.5))<1e-15,"mpa_test31") -throw_unless(abs(y[4,0,1]-(3+5.5))<1e-15,"mpa_test32") -exit(1) +exit_unless(ni[4,0]==2,"mpa_test30") +exit_unless(abs(y[4,0,0]-(3+1.5))<1e-15,"mpa_test31") +exit_unless(abs(y[4,0,1]-(3+5.5))<1e-15,"mpa_test32") +exit(0) diff --git a/pub/ftest/mr_by_int.f2t b/pub/ftest/mr_by_int.f2t index 8ceb71db2a8c34de0ce6051bc95318bd49aa1e97..1fda00f53a873744acef50d4c73c8461f822692f 100755 --- a/pub/ftest/mr_by_int.f2t +++ b/pub/ftest/mr_by_int.f2t @@ -3,4 +3,4 @@ fm 7 7 h oy j+i oi avge 1 mr y[2,0,j]>7 -exit(1) +exit(0) diff --git a/pub/ftest/nj_of_i.f2t b/pub/ftest/nj_of_i.f2t index 598848d3c1094c74dde063276010cc5c0d4d97e5..a6730e0a7e60c12a293ad89d67e0b4301d2eecec 100755 --- a/pub/ftest/nj_of_i.f2t +++ b/pub/ftest/nj_of_i.f2t @@ -4,5 +4,5 @@ fm 1 2 h2 fm 1 3 h3 fm 3 1 out oy nj[i] -throw_unless(sum==6,"sum_wrong") -exit(1) \ No newline at end of file +exit_unless(sum==6,"sum_wrong") +exit(0) \ No newline at end of file diff --git a/pub/ftest/oi_avge.f2t b/pub/ftest/oi_avge.f2t index a824c2b717b5ef9ea79696fc0e08e9e7376583b4..7cc4ea4ab09c16175792c7abdab4d9b1bd106586 100755 --- a/pub/ftest/oi_avge.f2t +++ b/pub/ftest/oi_avge.f2t @@ -1,5 +1,5 @@ #!/usr/bin/env frida fm 11 1 h oy i -throw_unless(avge==5,"final_result_wrong") -exit(1) \ No newline at end of file +exit_unless(avge==5,"final_result_wrong") +exit(0) \ No newline at end of file diff --git a/pub/ftest/oi_p.f2t b/pub/ftest/oi_p.f2t index 128e95fd86fddbf307c3006c96af6e1824edf984..e294b734838ffe7dd3a0cf71aa7f8648b72419c7 100755 --- a/pub/ftest/oi_p.f2t +++ b/pub/ftest/oi_p.f2t @@ -3,5 +3,5 @@ fm 3 3 h cc p0*t op0 j+.77 oi p0 -throw_unless(y[,,2]==2.77,"final_result_wrong") -exit(1) \ No newline at end of file +exit_unless(y[,,2]==2.77,"final_result_wrong") +exit(0) \ No newline at end of file diff --git a/pub/ftest/oy1.f2t b/pub/ftest/oy1.f2t index 71b55adc0e81f0d245fc71db8b60ed446f930a5f..f85f08bdedf44ef2ff5e7aa1a040a84286d87dda 100755 --- a/pub/ftest/oy1.f2t +++ b/pub/ftest/oy1.f2t @@ -4,5 +4,5 @@ ox! i oy! j+i oz0! j oy x+z0 -throw_unless(y[0,2,7]==9&&y[1,2,7]==9,"final_result_wrong") -exit(1) \ No newline at end of file +exit_unless(y[0,2,7]==9&&y[1,2,7]==9,"final_result_wrong") +exit(0) \ No newline at end of file diff --git a/pub/ftest/oy_arg_collat.f2t b/pub/ftest/oy_arg_collat.f2t index 23c11be8ba3be1146283589e7bcca23b7f87a7ef..e14639765a6b4ceb6045c30fc66f463662ba343e 100755 --- a/pub/ftest/oy_arg_collat.f2t +++ b/pub/ftest/oy_arg_collat.f2t @@ -5,5 +5,5 @@ fm 7 1 h oy! i 0 oy y/y[1,0] df -throw_unless(y[2,2,6]==3,"final_result_wrong") -exit(1) \ No newline at end of file +exit_unless(y[2,2,6]==3,"final_result_wrong") +exit(0) \ No newline at end of file diff --git a/pub/ftest/oz.f2t b/pub/ftest/oz.f2t index 41207107bc2741ea938a0ce88522e2e3f8c8fa08..cca7f756dff8704f93ce49d7f7ba321c4436f706 100755 --- a/pub/ftest/oz.f2t +++ b/pub/ftest/oz.f2t @@ -2,4 +2,5 @@ fm 7 3 h oz+ 100*j mz- 0 -exit(z0[,2]==200) \ No newline at end of file +exit_unless(z0[,2]==200,"failed") +exit(0) \ No newline at end of file diff --git a/pub/ftest/r_of_i.f2t b/pub/ftest/r_of_i.f2t index c1e39f0c006111a2b8ecb60f304813296ec445cf..915e2c8c1b9caf964c3beb5075722e58be9f33c7 100755 --- a/pub/ftest/r_of_i.f2t +++ b/pub/ftest/r_of_i.f2t @@ -2,5 +2,5 @@ fm 1 1 h or+ 77 oy r0[1+i] -throw_unless(y==77,"result_wrong") -exit(1) \ No newline at end of file +exit_unless(y==77,"result_wrong") +exit(0) \ No newline at end of file diff --git a/pub/ftest/run b/pub/ftest/run index 684450f243018a53baf79e617639d5e4c1645924..a73476746cf8e325953fefa1136fac91c1cacb20 100755 --- a/pub/ftest/run +++ b/pub/ftest/run @@ -4,11 +4,11 @@ COUNTER=0 rm -f log.tmp for I in *.f2t; do ./$I >> log.tmp - if [ $? = 1 ]; then + if [ $? = 0 ]; then echo "passed $I" else echo "FAILED $I" let COUNTER=COUNTER+1 - fi + fi done echo "=> $COUNTER failures. See log.tmp for full dialogs." diff --git a/pub/ftest/spheres_raw.f2t b/pub/ftest/spheres_raw.f2t index fd4c3aa926330d2095a8501447f5830199f62dab..2c25e53238cb497bfe8d262aeabeb12ff1d8d69a 100755 --- a/pub/ftest/spheres_raw.f2t +++ b/pub/ftest/spheres_raw.f2t @@ -1,5 +1,5 @@ #!/usr/bin/env frida ry8 spheres_raw 0 -throw_unless(nk==8,"failed") -exit(1) +exit_unless(nk==8,"failed") +exit(0) diff --git a/pub/ftest/ternary.f2t b/pub/ftest/ternary.f2t index ca9c42f529241caf61fa6ccd10fa52d8e2ed6416..6be247255236269318a06986a96c4121db02e3d8 100755 --- a/pub/ftest/ternary.f2t +++ b/pub/ftest/ternary.f2t @@ -1,4 +1,4 @@ #!/usr/bin/env frida -throw_unless(0?2:3==3,"cond_expr_failed") -throw_unless(1?4:5==4,"cond_expr_failed") -exit(1) +exit_unless(0?2:3==3,"cond_expr_failed") +exit_unless(1?4:5==4,"cond_expr_failed") +exit(0) diff --git a/pub/lib/fbase.cpp b/pub/lib/fbase.cpp index 72031fe3c03c42b8efcfd64d3e3f49c1b606a7ac..2c2d61d4d8e11c8bec17173fbbacf40614b8218c 100644 --- a/pub/lib/fbase.cpp +++ b/pub/lib/fbase.cpp @@ -169,8 +169,8 @@ double func_diehl( double a ) { int func_exit( int a ) { exit(a); return 0; } -int func_throw_if( int a, string s ) { if(a) throw s; return 0; } -int func_throw_unless( int a, string s ) { if(!a) throw s; return 0; } +int func_exit_if( int a, string s ) { if(a) { cerr << s << "\n"; exit(1); } return 0; } +int func_exit_unless( int a, string s ) { return func_exit_if( !a, s ); } //************************************************************************************************** //* Functions of two arguments @@ -591,10 +591,10 @@ void fbase_initialize() G->register_fct_d_d ( "lndiehl", func_lndiehl ); // f(2 args) - G->register_fct_meta ( "throw_if", 2, "(x,s): throw s if x" ); - G->register_fct_i_is ( "throw_if", func_throw_if ); - G->register_fct_meta ( "throw_unless", 1, "(x,s): throw s if !x" ); - G->register_fct_i_is ( "throw_unless", func_throw_unless ); + G->register_fct_meta ( "exit_if", 2, "(x,s): throw s if x" ); + G->register_fct_i_is ( "exit_if", func_exit_if ); + G->register_fct_meta ( "exit_unless", 1, "(x,s): throw s if !x" ); + G->register_fct_i_is ( "exit_unless", func_exit_unless ); G->register_fct_meta ( "min2", 2, "(x,y): the smaller of the two arguments x and y" ); G->register_fct_i_ii ( "min2", func_min ); G->register_fct_d_dd ( "min2", func_min ); diff --git a/pub/utest/CMakeLists.txt b/pub/utest/CMakeLists.txt index 2903d3c453d3f99e64108d793912acd63ab3cf3e..8ac2b8eb8d3d51aeaf2a3ecda721b7c295f69920 100644 --- a/pub/utest/CMakeLists.txt +++ b/pub/utest/CMakeLists.txt @@ -1,13 +1,12 @@ -# CMake build script for Tests +# To run the tests on Linux, use 'make test' or 'ctest'. +# To select which tests to run, use 'ctest -R regex'. +# To see output from the individual tests, use 'ctest -V'. +# For more options, run 'ctest --help'. include(cmake/utils.cmake) # defines cxx_executable, cxx_test enable_testing() -# To run the tests on Linux, use 'make test' or 'ctest'. -# You can select which tests to run using 'ctest -R regex'. -# For more options, run 'ctest --help'. - include_directories( ${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR} @@ -32,7 +31,7 @@ set(test_link_libs ) # We glob test sources, though this is often considered evil. -# Just touch Tests/CMakeLists.txt each time a test is added or withdrawn. +# Just touch CMakeLists.txt each time a test is added or withdrawn. file(GLOB test_sources "test[0-9]*.cpp")