db40d1abf3ebb2a82802080bb8c5672686665504
[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 STAT_CONFIG_PATH=$top_srcdir/config
14 export STAT_CONFIG_PATH
15
16
17 cleanup()
18 {
19      cd /
20      rm -rf $TEMPDIR
21 }
22
23
24 fail()
25 {
26     echo $activity
27     echo FAILED
28     cleanup;
29     exit 1;
30 }
31
32
33 no_result()
34 {
35     echo $activity
36     echo NO RESULT;
37     cleanup;
38     exit 2;
39 }
40
41 pass()
42 {
43     cleanup;
44     exit 0;
45 }
46
47 mkdir -p $TEMPDIR
48
49 cd $TEMPDIR
50
51 activity="create flip.stat"
52 cat > $TEMPDIR/flip.stat <<EOF
53 data list /N 1 (a) A B C D 2-9.
54 list.
55 begin data.
56 v 1 2 3 4 5
57 w 6 7 8 910
58 x1112131415
59 y1617181920
60 z2122232425
61 end data.
62 flip newnames=n.
63 list.
64 flip.
65 list.
66 EOF
67 if [ $? -ne 0 ] ; then no_result ; fi
68
69
70 activity="run program"
71 $SUPERVISOR $here/../src/pspp -o raw-ascii $TEMPDIR/flip.stat
72 if [ $? -ne 0 ] ; then no_result ; fi
73
74 activity="compare output"
75 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
76 diff  -b  $TEMPDIR/pspp.list - << EOF
77 1.1 DATA LIST.  Reading 1 record from INLINE.
78 +--------+------+-------+------+
79 |Variable|Record|Columns|Format|
80 #========#======#=======#======#
81 |N       |     1|  1-  1|A1    |
82 |A       |     1|  2-  3|F2.0  |
83 |B       |     1|  4-  5|F2.0  |
84 |C       |     1|  6-  7|F2.0  |
85 |D       |     1|  8-  9|F2.0  |
86 +--------+------+-------+------+
87 N  A  B  C  D
88 - -- -- -- --
89 v  1  2  3  4 
90 w  6  7  8  9 
91 x 11 12 13 14 
92 y 16 17 18 19 
93 z 21 22 23 24 
94 CASE_LBL        V        W        X        Y        Z
95 -------- -------- -------- -------- -------- --------
96 A            1.00     6.00    11.00    16.00    21.00 
97 B            2.00     7.00    12.00    17.00    22.00 
98 C            3.00     8.00    13.00    18.00    23.00 
99 D            4.00     9.00    14.00    19.00    24.00 
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;