98b2c078dd1f03357103bc3377a7235d685b35fe
[pspp-builds.git] / tests / command / autorecod.sh
1 #!/bin/sh
2
3 # This program tests the autorecode command
4
5 TEMPDIR=/tmp/pspp-tst-$$
6 TESTFILE=$TEMPDIR/`basename $0`.sps
7
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 /* Tries AUTORECODE on some random but similar strings of characters.
53 data list /X 1-5(a) Y 7.
54 begin data.
55 lasdj 1 1                                                           3
56 asdfk 0 3 <---- These are the numbers that should be produced for a 4
57 asdfj 2 4                                                           2
58 asdfj 1 4                                                           3
59 asdfk 2 3                                                           2
60 asdfj 9 4                                                           1
61 lajks 9 2                                                           1
62 asdfk 0 3 These are the numbers that should be produced for b ----> 4
63 asdfk 1 3                                                           3
64 end data.
65
66 autorecode x y into A B/descend.
67
68 list.
69 /* Just to make sure it works on second & subsequent executions,
70 /* try it again.
71 compute Z=trunc(y/2).
72 autorecode z into W.
73 list.
74 EOF
75 if [ $? -ne 0 ] ; then no_result ; fi
76
77 activity="run program"
78 $SUPERVISOR $here/../src/pspp    -o raw-ascii $TESTFILE
79 if [ $? -ne 0 ] ; then no_result ; fi
80
81 activity="test output"
82 diff -b -B $TEMPDIR/pspp.list - <<EOF
83 1.1 DATA LIST.  Reading 1 record from the command file.
84 +--------+------+-------+------+
85 |Variable|Record|Columns|Format|
86 #========#======#=======#======#
87 |X       |     1|  1-  5|A5    |
88 |Y       |     1|  7-  7|F1.0  |
89 +--------+------+-------+------+
90
91     X Y        A        B
92 ----- - -------- --------
93 lasdj 1     1.00     3.00 
94 asdfk 0     3.00     4.00 
95 asdfj 2     4.00     2.00 
96 asdfj 1     4.00     3.00 
97 asdfk 2     3.00     2.00 
98 asdfj 9     4.00     1.00 
99 lajks 9     2.00     1.00 
100 asdfk 0     3.00     4.00 
101 asdfk 1     3.00     3.00 
102
103     X Y        A        B        Z        W
104 ----- - -------- -------- -------- --------
105 lasdj 1     1.00     3.00      .00     1.00 
106 asdfk 0     3.00     4.00      .00     1.00 
107 asdfj 2     4.00     2.00     1.00     2.00 
108 asdfj 1     4.00     3.00      .00     1.00 
109 asdfk 2     3.00     2.00     1.00     2.00 
110 asdfj 9     4.00     1.00     4.00     3.00 
111 lajks 9     2.00     1.00     4.00     3.00 
112 asdfk 0     3.00     4.00      .00     1.00 
113 asdfk 1     3.00     3.00      .00     1.00 
114 EOF
115 if [ $? -ne 0 ] ; then fail ; fi
116
117 pass
118
119
120