Internationalisation.
[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 # ensure that top_builddir  are absolute
10 if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
11 if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
12 top_builddir=`cd $top_builddir; pwd`
13 PSPP=$top_builddir/src/ui/terminal/pspp
14
15 # ensure that top_srcdir is absolute
16 top_srcdir=`cd $top_srcdir; pwd`
17
18 STAT_CONFIG_PATH=$top_srcdir/config
19 export STAT_CONFIG_PATH
20
21 LANG=C
22 export LANG
23
24 cleanup()
25 {
26      cd /
27      rm -rf $TEMPDIR
28 }
29
30
31 fail()
32 {
33     echo $activity
34     echo FAILED
35     cleanup;
36     exit 1;
37 }
38
39
40 no_result()
41 {
42     echo $activity
43     echo NO RESULT;
44     cleanup;
45     exit 2;
46 }
47
48 pass()
49 {
50     cleanup;
51     exit 0;
52 }
53
54 mkdir -p $TEMPDIR
55
56 cd $TEMPDIR
57
58 activity="create program"
59 cat > $TESTFILE <<EOF
60 /* Tries AUTORECODE on some random but similar strings of characters.
61 data list /X 1-5(a) Y 7.
62 begin data.
63 lasdj 1 1                                                           3
64 asdfk 0 3 <---- These are the numbers that should be produced for a 4
65 asdfj 2 4                                                           2
66 asdfj 1 4                                                           3
67 asdfk 2 3                                                           2
68 asdfj 9 4                                                           1
69 lajks 9 2                                                           1
70 asdfk 0 3 These are the numbers that should be produced for b ----> 4
71 asdfk 1 3                                                           3
72 end data.
73
74 autorecode x y into A B/descend.
75
76 list.
77 /* Just to make sure it works on second & subsequent executions,
78 /* try it again.
79 compute Z=trunc(y/2).
80 autorecode z into W.
81 list.
82 EOF
83 if [ $? -ne 0 ] ; then no_result ; fi
84
85 activity="run program"
86 $SUPERVISOR $PSPP    -o raw-ascii $TESTFILE
87 if [ $? -ne 0 ] ; then no_result ; fi
88
89 activity="test output"
90 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
91 diff -b $TEMPDIR/pspp.list - <<EOF
92 1.1 DATA LIST.  Reading 1 record from INLINE.
93 +--------+------+-------+------+
94 |Variable|Record|Columns|Format|
95 #========#======#=======#======#
96 |X       |     1|  1-  5|A5    |
97 |Y       |     1|  7-  7|F1.0  |
98 +--------+------+-------+------+
99     X Y        A        B
100 ----- - -------- --------
101 lasdj 1     1.00     3.00 
102 asdfk 0     3.00     4.00 
103 asdfj 2     4.00     2.00 
104 asdfj 1     4.00     3.00 
105 asdfk 2     3.00     2.00 
106 asdfj 9     4.00     1.00 
107 lajks 9     2.00     1.00 
108 asdfk 0     3.00     4.00 
109 asdfk 1     3.00     3.00 
110     X Y        A        B        Z        W
111 ----- - -------- -------- -------- --------
112 lasdj 1     1.00     3.00      .00     1.00 
113 asdfk 0     3.00     4.00      .00     1.00 
114 asdfj 2     4.00     2.00     1.00     2.00 
115 asdfj 1     4.00     3.00      .00     1.00 
116 asdfk 2     3.00     2.00     1.00     2.00 
117 asdfj 9     4.00     1.00     4.00     3.00 
118 lajks 9     2.00     1.00     4.00     3.00 
119 asdfk 0     3.00     4.00      .00     1.00 
120 asdfk 1     3.00     3.00      .00     1.00 
121 EOF
122 if [ $? -ne 0 ] ; then fail ; fi
123
124 pass
125
126
127