Sat Jul 30 21:54:23 2005 Ben Pfaff <blp@gnu.org>
[pspp-builds.git] / tests / command / longvars.sh
1 #!/bin/sh
2
3 # This program tests that both long and short variable names are parsed OK.
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 # Use crosstabs, since its TABLES subcommand exercises the array var set 
52 # feature.
53 activity="create program"
54 cat > $TESTFILE <<EOF
55 DATA LIST LIST /AlphaBetaGamma * B * X * Yabbadabbadoo * .
56 BEGIN DATA.
57 2 3 4 5
58 END DATA.
59
60 LIST.
61
62 CROSSTABS 
63         VARIABLES X (1,7) Yabbadabbadoo (1,7) 
64         /TABLES X BY Yabbadabbadoo.
65 EOF
66 if [ $? -ne 0 ] ; then no_result ; fi
67
68
69 activity="run program"
70 $SUPERVISOR $here/../src/pspp -o raw-ascii $TESTFILE
71 if [ $? -ne 0 ] ; then no_result ; fi
72
73 activity="compare output"
74 diff -B -b $TEMPDIR/pspp.list - <<EOF
75 1.1 DATA LIST.  Reading free-form data from the command file.
76 +--------------+------+
77 |   Variable   |Format|
78 #==============#======#
79 |AlphaBetaGamma|F8.0  |
80 |B             |F8.0  |
81 |X             |F8.0  |
82 |Yabbadabbadoo |F8.0  |
83 +--------------+------+
84
85 AlphaBetaGamma        B        X Yabbadabbadoo
86 -------------- -------- -------- -------------
87           2.00     3.00     4.00          5.00 
88
89 2.1 CROSSTABS.  Summary.
90 #===============#=====================================================#
91 #               #                        Cases                        #
92 #               #-----------------+-----------------+-----------------#
93 #               #      Valid      |     Missing     |      Total      #
94 #               #--------+--------+--------+--------+--------+--------#
95 #               #       N| Percent|       N| Percent|       N| Percent#
96 #---------------#--------+--------+--------+--------+--------+--------#
97 #X *            #       1|  100.0%|       0|    0.0%|       1|  100.0%#
98 #Yabbadabbadoo  #        |        |        |        |        |        #
99 #===============#========#========#========#========#========#========#
100
101 2.2 CROSSTABS.  X by Yabbadabbadoo [count].
102 #===============#==============================================================#========#
103 #               #                         Yabbadabbadoo                        |        #
104 #               #--------+--------+--------+--------+--------+--------+--------+        #
105 #              X#    1.00|    2.00|    3.00|    4.00|    5.00|    6.00|    7.00|  Total #
106 #---------------#--------+--------+--------+--------+--------+--------+--------+--------#
107 #           1.00#      .0|      .0|      .0|      .0|      .0|      .0|      .0|      .0#
108 #           2.00#      .0|      .0|      .0|      .0|      .0|      .0|      .0|      .0#
109 #           3.00#      .0|      .0|      .0|      .0|      .0|      .0|      .0|      .0#
110 #           4.00#      .0|      .0|      .0|      .0|     1.0|      .0|      .0|     1.0#
111 #           5.00#      .0|      .0|      .0|      .0|      .0|      .0|      .0|      .0#
112 #           6.00#      .0|      .0|      .0|      .0|      .0|      .0|      .0|      .0#
113 #           7.00#      .0|      .0|      .0|      .0|      .0|      .0|      .0|      .0#
114 #Total          #     .0%|     .0%|     .0%|     .0%|    1.0%|     .0%|     .0%|    1.0%#
115 #===============#========#========#========#========#========#========#========#========#
116
117 EOF
118 if [ $? -ne 0 ] ; then fail ; fi
119
120
121 pass