72da71fcd5436841d553c05a76fb6c331126ac93
[pspp-builds.git] / tests / bugs / random.sh
1 #!/bin/sh
2
3 # This program tests for a bug which caused UNIFORM(x) to always return zero.
4
5
6 TEMPDIR=/tmp/pspp-tst-$$
7
8 here=`pwd`;
9
10 # ensure that top_srcdir is absolute
11 cd $top_srcdir; top_srcdir=`pwd`
12
13 export STAT_CONFIG_PATH=$top_srcdir/config
14
15
16 cleanup()
17 {
18      rm -rf $TEMPDIR
19 }
20
21
22 fail()
23 {
24     echo $activity
25     echo FAILED
26     cleanup;
27     exit 1;
28 }
29
30
31 no_result()
32 {
33     echo $activity
34     echo NO RESULT;
35     cleanup;
36     exit 2;
37 }
38
39 pass()
40 {
41     cleanup;
42     exit 0;
43 }
44
45 mkdir -p $TEMPDIR
46
47 cd $TEMPDIR
48
49 activity="create program"
50 cat > $TEMPDIR/rnd.sps <<EOF
51 set seed=10.
52 input program.
53 + loop #i = 1 to 20.
54 +    do repeat response=r1.
55 +       compute response = uniform(10).
56 +    end repeat.
57 +    end case.
58 + end loop.
59 + end file.
60 end input program.                                                              
61
62 list.
63 EOF
64 if [ $? -ne 0 ] ; then no_result ; fi
65
66 $SUPERVISOR $here/../src/pspp -o raw-ascii $TEMPDIR/rnd.sps
67 if [ $? -ne 0 ] ; then no_result ; fi
68
69
70 diff -b -B -w $TEMPDIR/pspp.list - << EOF
71       R1
72 --------
73     2.36 
74     3.13 
75     1.76 
76      .15 
77     5.88 
78     8.74 
79     2.19 
80     6.53 
81     5.69 
82     6.77 
83     7.20 
84     4.01 
85      .03 
86     4.67 
87     5.10 
88      .44 
89     8.27 
90     6.81 
91     9.55 
92     8.74 
93 EOF
94 if [ $? -ne 0 ] ; then fail ; fi
95
96 pass;