// Declaration, assignment tests // $Id: test_float.exper,v 1.34 2002/04/25 16:24:25 boissieu Exp $ define float a = true define float b = 2.0 define float c = false // Comparisons tests if a > b then error a ">" b end if b < a then error b "<" a end if b != 2.0 then error b "!=" 2.0 end if a == 2.0 then error a "==" 2.0 end if ! (b >= c) then error "! (" b " >= " c ")" end if ! (b <= 2.0) then error "!("b"<=" 2.0")" end if ! (b >= 2.0) then error "!(" b ">=" 2.0 ")" end // Arithmetic tests define float r = 2 * b + a if r != 5.0 then error "2*2+1 = " r end if -a != -1.0 then error "UMINUS don't work" end if 2 / 2 * 2 != 2 then error "Division precedence" end if |-2| != 2 then error "fabs()" end define float num = 5.8 define float quot = 3.1 if ceil(num) != 6.0 then error "ceil failure" end if floor(num) != 5.0 then error "floor failure" end if num % quot != 2.0 then error " modulo failure" end // Explicit string convertion set r = 3.14159 if "3.14159" != string(r) then error "Explicit convertion to string failed : " r end // Logical operators tests define float d = !b if d then error "d should be false" end set d = !c if !d then error "d should be true" end if !(b && b) then error "T && T should be T" end if (b && c) then error "T && F should be F" end if (c && b) then error "F && T should be F" end if (c && c) then error "F && F should be F" end if !(b || b) then error "T || T should be T" end if !(b || c) then error "T || F should be T" end if !(c || b) then error "F || T should be T" end if (c || c) then error "F || F should be F" end if !(c && b) != (c || b) then error "!(F && T) and (F || T) should be equivalent" end if a < b || a < c then if a < c then error "a minimum" else end else error "a maximum" end print "========= test_float passed OK" quit