d2c1061432d5e815b9a70195ec7ee5109fb4354e
[pspp-builds.git] / tests / bugs / temp-freq.sh
1 #!/bin/sh
2
3 # This program tests for a bug which caused FREQUENCIES following
4 # TEMPORARY to crash (PR 11492).
5
6 TEMPDIR=/tmp/pspp-tst-$$
7 TESTFILE=$TEMPDIR/`basename $0`.sps
8
9 here=`pwd`;
10
11 # ensure that top_srcdir is absolute
12 cd $top_srcdir; top_srcdir=`pwd`
13
14 export STAT_CONFIG_PATH=$top_srcdir/config
15
16
17 cleanup()
18 {
19      rm -rf $TEMPDIR
20 }
21
22
23 fail()
24 {
25     echo $activity
26     echo FAILED
27     cleanup;
28     exit 1;
29 }
30
31
32 no_result()
33 {
34     echo $activity
35     echo NO RESULT;
36     cleanup;
37     exit 2;
38 }
39
40 pass()
41 {
42     cleanup;
43     exit 0;
44 }
45
46 mkdir -p $TEMPDIR
47
48 cd $TEMPDIR
49
50 activity="create program"
51 cat > $TESTFILE <<EOF
52 DATA LIST LIST /SEX (A1) X *.
53 BEGIN DATA.
54 M 31
55 F 21
56 M 41
57 F 31
58 M 13
59 F 12
60 M 14
61 F 13
62 END DATA.
63
64
65 TEMPORARY
66 SELECT IF SEX EQ 'F'
67 FREQUENCIES /X .
68
69 FINISH
70 EOF
71 if [ $? -ne 0 ] ; then no_result ; fi
72
73 $SUPERVISOR $here/../src/pspp -o raw-ascii $TESTFILE
74 if [ $? -ne 0 ] ; then no_result ; fi
75
76 diff -b -B -w $TEMPDIR/pspp.list - << EOF
77 1.1 DATA LIST.  Reading free-form data from the command file.
78 +--------+------+
79 |Variable|Format|
80 #========#======#
81 |SEX     |A1    |
82 |X       |F8.0  |
83 +--------+------+
84
85 2.1 FREQUENCIES.  X: 
86 +-----------+--------+---------+--------+--------+--------+
87 |           |        |         |        |  Valid |   Cum  |
88 |Value Label|  Value |Frequency| Percent| Percent| Percent|
89 #===========#========#=========#========#========#========#
90 |           |   12.00|        1|    25.0|    25.0|    25.0|
91 |           |   13.00|        1|    25.0|    25.0|    50.0|
92 |           |   21.00|        1|    25.0|    25.0|    75.0|
93 |           |   31.00|        1|    25.0|    25.0|   100.0|
94 #===========#========#=========#========#========#========#
95 |               Total|        4|   100.0|   100.0|        |
96 +--------------------+---------+--------+--------+--------+
97
98 +---------------+------+
99 |N       Valid  |     4|
100 |        Missing|     0|
101 |Mean           |19.250|
102 |Std Dev        | 8.808|
103 |Minimum        |12.000|
104 |Maximum        |31.000|
105 +---------------+------+
106
107 EOF
108 if [ $? -ne 0 ] ; then fail ; fi
109
110 pass;