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