Added tests for descriptives and flip
[pspp-builds.git] / tests / command / flip.sh
1 #!/bin/sh
2
3 # This program tests the flip command
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 flip.stat"
49 cat > $TEMPDIR/flip.stat <<EOF
50 data list /n 1 (a) a b c d 2-9.
51 list.
52 begin data.
53 v 1 2 3 4 5
54 w 6 7 8 910
55 x1112131415
56 y1617181920
57 z2122232425
58 end data.
59 flip newnames=n.
60 list.
61 flip.
62 list.
63 EOF
64 if [ $? -ne 0 ] ; then no_result ; fi
65
66
67 activity="run program"
68 $here/../src/pspp -o raw-ascii $TEMPDIR/flip.stat
69 if [ $? -ne 0 ] ; then no_result ; fi
70
71 activity="compare output"
72 diff  -b -B $TEMPDIR/pspp.list - << EOF
73 1.1 DATA LIST.  Reading 1 record from the command file.
74 +--------+------+-------+------+
75 |Variable|Record|Columns|Format|
76 #========#======#=======#======#
77 |N       |     1|  1-  1|A1    |
78 |A       |     1|  2-  3|F2.0  |
79 |B       |     1|  4-  5|F2.0  |
80 |C       |     1|  6-  7|F2.0  |
81 |D       |     1|  8-  9|F2.0  |
82 +--------+------+-------+------+
83
84 N  A  B  C  D
85 - -- -- -- --
86 v  1  2  3  4 
87 w  6  7  8  9 
88 x 11 12 13 14 
89 y 16 17 18 19 
90 z 21 22 23 24 
91
92 CASE_LBL        V        W        X        Y        Z
93 -------- -------- -------- -------- -------- --------
94 A            1.00     6.00    11.00    16.00    21.00 
95 B            2.00     7.00    12.00    17.00    22.00 
96 C            3.00     8.00    13.00    18.00    23.00 
97 D            4.00     9.00    14.00    19.00    24.00 
98
99 CASE_LBL        A        B        C        D
100 -------- -------- -------- -------- --------
101 V            1.00     2.00     3.00     4.00 
102 W            6.00     7.00     8.00     9.00 
103 X           11.00    12.00    13.00    14.00 
104 Y           16.00    17.00    18.00    19.00 
105 Z           21.00    22.00    23.00    24.00 
106 EOF
107 if [ $? -ne 0 ] ; then fail ; fi
108
109
110 pass;