1ccc09ba4fa59ca1a0a5b02a92041d20653fd7b9
[pspp] / tests / command / bignum.sh
1 #!/bin/sh
2
3 # This program tests the use of big numbers
4
5 TEMPDIR=/tmp/pspp-tst-$$
6
7 here=`pwd`;
8
9 # ensure that top_srcdir is absolute
10 cd $top_srcdir; top_srcdir=`pwd`
11
12 export STAT_CONFIG_PATH=$top_srcdir/config
13
14
15 cleanup()
16 {
17      rm -rf $TEMPDIR
18 }
19
20
21 fail()
22 {
23     echo $activity
24     echo FAILED
25     cleanup;
26     exit 1;
27 }
28
29
30 no_result()
31 {
32     echo $activity
33     echo NO RESULT;
34     cleanup;
35     exit 2;
36 }
37
38 pass()
39 {
40     cleanup;
41     exit 0;
42 }
43
44 mkdir -p $TEMPDIR
45
46 cd $TEMPDIR
47
48 activity="create data file"
49 cat > $TEMPDIR/bignum.data << wizzah
50 0
51 0.1
52 0.5
53 0.8
54 0.9
55 0.999
56 1
57 2
58 3
59 4
60 5
61 12
62 123
63 1234
64 12345
65 123456
66 1234567
67 12345678
68 123456789
69 1234567890
70 19999999999
71 199999999999
72 1234567890123
73 19999999999999
74 199999999999999
75 1234567890123456
76 19999999999999999
77 123456789012345678
78 1999999999999999999
79 12345678901234567890
80 199999999999999999999
81 1234567890123456789012
82 19999999999999999999999
83 123456789012345678901234
84 1999999999999999999999999
85 12345678901234567890123456
86 199999999999999999999999999
87 1234567890123456789012345678
88 19999999999999999999999999999
89 123456789012345678901234567890
90 1999999999999999999999999999999
91 12345678901234567890123456789012
92 199999999999999999999999999999999
93 1234567890123456789012345678901234
94 19999999999999999999999999999999999
95 123456789012345678901234567890123456
96 1999999999999999999999999999999999999
97 12345678901234567890123456789012345678
98 199999999999999999999999999999999999999
99 1234567890123456789012345678901234567890
100 1999999999999999999999999999999999999999
101 1e40
102 1.1e40
103 1.5e40
104 1e41
105 1e50
106 1e100
107 1e150
108 1e200
109 1e250
110 1e300
111 1.79641e308
112 wizzah
113 if [ $? -ne 0 ] ; then no_result ; fi
114
115
116 activity="create program"
117 cat > $TEMPDIR/prog.stat <<foobar
118 title 'Test use of big numbers'.
119
120 *** Do the portable output.
121 remark EOF
122 ----------------------------------------------------------------------
123 Testing use of big numbers.\n
124 The numbers in the data file are designed for IEEE754 double
125 format--if your system uses something different then the test needs to
126 be adjusted for whatever are big numbers to your system.
127 ----------------------------------------------------------------------
128 EOF
129 data list file='$TEMPDIR/bignum.data'/BIGNUM 1-40.
130 list.
131
132 *** Do the nonportable output for fun. 
133 remark EOF
134 NOCOMP
135 SUCCESS?
136 ----------------------------------------------------------------------
137 This test merely shows whether your system can successfully handle
138 floating-point overflow.  If you get a fatal exception at this point,
139 the source needs some editing--glob.c should mask overflow exceptions
140 in init_glob().  Again, the numbers are specific to IEEE754 double
141 format.
142 ----------------------------------------------------------------------
143 EOF
144 descriptives BIGNUM.
145 rem-SUCCESS
146 foobar
147 if [ $? -ne 0 ] ; then no_result ; fi
148
149 activity="run program"
150 $SUPERVISOR $here/../src/pspp -o raw-ascii prog.stat
151 if [ $? -ne 0 ] ; then no_result ; fi
152
153 # Like the above comments say ...
154 # ... if we get here without crashing, then the test has passed.
155
156 pass;