Make the expression code a little nicer and fix bugs found
[pspp-builds.git] / 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 data list file='$TEMPDIR/bignum.data'/BIGNUM 1-40.
122 list.
123
124 *** Do the nonportable output for fun. 
125 descriptives BIGNUM.
126 foobar
127 if [ $? -ne 0 ] ; then no_result ; fi
128
129 activity="run program"
130 $SUPERVISOR $here/../src/pspp -o raw-ascii prog.stat
131 if [ $? -ne 0 ] ; then no_result ; fi
132
133 # Like the above comments say ...
134 # ... if we get here without crashing, then the test has passed.
135
136 pass;