3 # tests if mawk has been compiled to correctly handle
4 # floating point exceptions
7 # Revision 1.3 1995/08/29 14:17:18 mike
10 # Revision 1.2 1994/12/18 18:51:55 mike
11 # recognize NAN printed as ? for hpux
16 test1='BEGIN{ print 4/0 }'
21 do { y = x ; x *= 1000 } while ( y != x )
22 print "loop terminated"
25 test3='BEGIN{ print log(-8) }'
28 echo "testing division by zero"
34 echo "testing overflow"
40 echo "testing domain error"
42 mawk "$test3" > temp$$
48 # the returns should all be zero or all 2
49 # core dumps not allowed
52 echo compilation defines for floating point are incorrect
57 echo ==============================
64 [ $ret1 -gt 128 ] && { echo test1 failed ; exception=1 ; }
65 [ $ret2 -gt 128 ] && { echo test2 failed ; exception=1 ; }
66 [ $ret3 -gt 128 ] && { echo test3 failed ; exception=1 ; }
68 [ "$exception" = 1 ] && { rm -f core temp$$ ; exit 1 ; }
73 [ $ret1 = $ret2 ] && [ $ret2 = $ret3 ] && same=1
80 echo results consistent: ignoring floating exceptions
81 # some versions of hpux print NAN as ?
82 if egrep '[nN][aA][nN]|\?' temp$$ > /dev/null
85 echo "but the library is not IEEE754 compatible"
89 else echo results consistent: trapping floating exceptions
97 echo results are not consistent
98 echo 'return values should all be 0 if ignoring FPEs (e.g. with IEEE754)
99 or all 2 if trapping FPEs'