Implemented the SHOW command and massaged the SET command to fit
[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 activity="run program"
67 $SUPERVISOR $here/../src/pspp -o raw-ascii $TEMPDIR/rnd.sps
68 if [ $? -ne 0 ] ; then no_result ; fi
69
70
71 activity="compare output"
72 diff -b -B -w $TEMPDIR/pspp.list - << EOF
73       R1
74 --------
75     2.36 
76     3.13 
77     1.76 
78      .15 
79     5.88 
80     8.74 
81     2.19 
82     6.53 
83     5.69 
84     6.77 
85     7.20 
86     4.01 
87      .03 
88     4.67 
89     5.10 
90      .44 
91     8.27 
92     6.81 
93     9.55 
94     8.74 
95 EOF
96 if [ $? -ne 0 ] ; then fail ; fi
97
98 pass;