Checkin of new directory structure.
[pspp-builds.git] / tests / command / missing-values.sh
1 #!/bin/sh
2
3 # This program tests MISSING VALUES
4
5 TEMPDIR=/tmp/pspp-tst-$$
6 TESTFILE=$TEMPDIR/`basename $0`.sps
7
8 # ensure that top_builddir  are absolute
9 if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
10 if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
11 top_builddir=`cd $top_builddir; pwd`
12
13 # ensure that top_srcdir is absolute
14 top_srcdir=`cd $top_srcdir; pwd`
15
16 STAT_CONFIG_PATH=$top_srcdir/config
17 export STAT_CONFIG_PATH
18
19
20 cleanup()
21 {
22      cd /
23      rm -rf $TEMPDIR
24 }
25
26
27 fail()
28 {
29     echo $activity
30     echo FAILED
31     cleanup;
32     exit 1;
33 }
34
35
36 no_result()
37 {
38     echo $activity
39     echo NO RESULT;
40     cleanup;
41     exit 2;
42 }
43
44 pass()
45 {
46     cleanup;
47     exit 0;
48 }
49
50 mkdir -p $TEMPDIR
51
52 cd $TEMPDIR
53
54 # Copy this file --- it's shared with another test
55 activity="create data"
56 cp $top_srcdir/tests/data-list.data $TEMPDIR
57 if [ $? -ne 0 ] ; then no_result ; fi
58
59
60 activity="create program"
61 cat > $TEMPDIR/missing-values.stat << foobar
62 DATA LIST NOTABLE/str1 1-5 (A) str2 6-8 (A) date1 9-19 (DATE) num1 20-25.
63
64 /* Valid: numeric missing values.
65 MISSING VALUES date1 num1 (1).
66 MISSING VALUES date1 num1 (1, 2).
67 MISSING VALUES date1 num1 (1, 2, 3).
68
69 /* Valid: numeric missing values using the first variable's format.
70 MISSING VALUES num1 date1 ('1').
71 MISSING VALUES num1 date1 ('1', '2').
72 MISSING VALUES num1 date1 ('1', '2', '3').
73 MISSING VALUES date1 num1 ('06-AUG-05').
74 MISSING VALUES date1 num1 ('06-AUG-05', '01-OCT-78').
75 MISSING VALUES date1 num1 ('06-AUG-05', '01-OCT-78', '14-FEB-81').
76
77 /* Valid: ranges of numeric missing values.
78 MISSING VALUES num1 (1 THRU 2).
79 MISSING VALUES num1 (LO THRU 2).
80 MISSING VALUES num1 (LOWEST THRU 2).
81 MISSING VALUES num1 (1 THRU HI).
82 MISSING VALUES num1 (1 THRU HIGHEST).
83
84 /* Valid: a range of numeric missing values, plus an individual value.
85 MISSING VALUES num1 (1 THRU 2, 3).
86 MISSING VALUES num1 (LO THRU 2, 3).
87 MISSING VALUES num1 (LOWEST THRU 2, 3).
88 MISSING VALUES num1 (1 THRU HI, -1).
89 MISSING VALUES num1 (1 THRU HIGHEST, -1).
90
91 /* Valid: string missing values.
92 MISSING VALUES str1 str2 ('abc  ','def').
93
94 /* Invalid: too long for str2.
95 MISSING VALUES str1 str2 ('abcde').
96
97 /* Invalid: no string ranges.
98 MISSING VALUES str1 ('a' THRU 'z').
99
100 /* Invalid: mixing string and numeric variables.
101 MISSING VALUES str1 num1 ('123').
102
103 /* Valid: may mix variable types when clearing missing values.
104 MISSING VALUES ALL ().
105
106 foobar
107 if [ $? -ne 0 ] ; then no_result ; fi
108
109
110 activity="run program"
111 $SUPERVISOR $top_builddir/src/pspp --testing-mode -o raw-ascii --testing-mode $TEMPDIR/missing-values.stat > $TEMPDIR/errs
112 # Note   vv   --- there are errors in input.  Therefore, the  command must FAIL
113 if [ $? -eq 0 ] ; then fail ; fi
114
115 activity="compare error messages"
116 diff -w $TEMPDIR/errs - <<EOF
117 $TEMPDIR/missing-values.stat:34: error: MISSING VALUES: Missing values provided are too long to assign to variable of width 3.
118 $TEMPDIR/missing-values.stat:34: warning: Skipping the rest of this command.  Part of this command may have been executed.
119 $TEMPDIR/missing-values.stat:37: error: MISSING VALUES: Syntax error expecting string at \`THRU'.
120 $TEMPDIR/missing-values.stat:37: error: MISSING VALUES: THRU is not a variable name.
121 $TEMPDIR/missing-values.stat:37: warning: Skipping the rest of this command.  Part of this command may have been executed.
122 $TEMPDIR/missing-values.stat:40: error: MISSING VALUES: Cannot mix numeric variables (e.g. num1) and string variables (e.g. str1) within a single list.
123 $TEMPDIR/missing-values.stat:40: warning: Skipping the rest of this command.  Part of this command may have been executed.
124 EOF
125 if [ $? -ne 0 ] ; then fail ; fi
126
127
128 pass;