/* * @progname st_trig.li * @version 0.9 (2008-01-05) * @author Perry Rapp * @category self-test * @output none * @description validate trig functions */ char_encoding("ASCII") require("lifelines-reports.version:1.3") option("explicitvars") /* Disallow use of undefined variables */ include("st_aux") /* entry point in case not invoked via st_all.ll */ proc main() { call testTrig() } /* return true if values match to specified deviation */ func matchx(val1, val2, dev) { if (or(gt(val1, add(val2, dev)), gt(val2, add(val1, dev)))) { return(0) } else { return(1) } } /* test some list functions */ proc testTrig() { call initSubsection() if (not(matchx(sin(45), 0.7071, 0.0001))) { call reportfail("sin(45) FAILED") } else { incr(testok) } if (not(matchx(cos(45), 0.7071, 0.0001))) { call reportfail("cos(45) FAILED") } else { incr(testok) } if (not(matchx(tan(45), 1.0, 0.0001))) { call reportfail("tan(45) FAILED") } else { incr(testok) } if (not(matchx(sin(0), 0, 0.0001))) { call reportfail("sin(0) FAILED") } else { incr(testok) } if (not(matchx(cos(0), 1, 0.0001))) { call reportfail("cos(0) FAILED") } else { incr(testok) } call reportSubsection("trig tests") }