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