File: fpe_test.bat

package info (click to toggle)
mawk 1.3.3-5
  • links: PTS
  • area: main
  • in suites: potato
  • size: 1,204 kB
  • ctags: 1,530
  • sloc: ansic: 13,023; yacc: 994; awk: 629; sh: 330; makefile: 164
file content (139 lines) | stat: -rw-r--r-- 2,396 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
echo off
rem  tests if mawk has been compiled to correctly handle
rem  floating point exceptions

echo testing division by zero
type fpetest1.awk
..\mawk -f fpetest1.awk
if errorlevel 128 goto :test1_128
if errorlevel 3 goto :test1_3
if errorlevel 2 goto :test1_2
if errorlevel 1 goto :test1_1
set ret1=0
goto :test2
:test1_128
set ret1=128
goto :test2
:test1_3
set ret1=3
goto :test2
:test1_2
set ret1=2
goto :test2
:test1_1
set ret1=1

:test2
echo testing overflow
type fpetest2.awk
..\mawk -f fpetest2.awk
if errorlevel 128 goto :test2_128
if errorlevel 3 goto :test2_3
if errorlevel 2 goto :test2_2
if errorlevel 1 goto :test2_1
set ret2=0
goto :test3
:test2_128
set ret2=128
goto :test3
:test2_3
set ret2=3
goto :test3
:test2_2
set ret2=2
goto :test3
:test2_1
set ret2=1

:test3
echo testing domain error
type fpetest3.awk
..\mawk -f fpetest3.awk > temp$$
if errorlevel 128 goto :test3_128
if errorlevel 3 goto :test3_3
if errorlevel 2 goto :test3_2
if errorlevel 1 goto :test3_1
set ret3=0
goto :type3
:test3_128
set ret3=128
goto :type3
:test3_3
set ret3=3
goto :type3
:test3_2
set ret3=2
goto :type3
:test3_1
set ret3=1

:type3
type temp$$

rem  the returns should all be zero or all 2

echo *************************************
echo return1 = %ret1%
echo return2 = %ret2%
echo return3 = %ret3%

set exception=0
if %ret1% == 2 goto :okay1
if %ret1% == 0 goto :okay1
echo test1 failed
set exception=1
:okay1
if %ret2% == 2 goto :okay2
if %ret2% == 0 goto :okay2
echo test2 failed
set exception=1
:okay2
if %ret3% == 2 goto :okay3
if %ret3% == 0 goto :okay3
echo test3 failed
set exception=1
:okay3

if %exception% == 1 goto :done

set same=1
if %ret1% == %ret2% goto :same12
set same=0
:same12
if %ret2% == %ret3% goto :same23
set same=0
:same23

if %same% == 1 goto :same123
echo results are not consistent
echo return values should all be 0 if ignoring FPEs (e.g. with IEEE754)
echo or all 2 if trapping FPEs
goto :cleanup

:same123
if %ret1% == 0 goto :allzero
echo results consistent: trapping floating exceptions
goto :cleanup

:allzero
echo results consistent: ignoring floating exceptions
grep -i nan temp$$ >NUL
if not errorlevel 1 goto :cleanup
echo but the library is not IEEE754 compatible
echo test 3 failed

:cleanup
del temp$$

:done
set ret1=
set ret2=
set ret3=
set same=
if %exception% == 1 goto :done1
set exception=
exit 0
:done1
set exception=
exit 1
exit %exception%