Added tests for LOOP and SAMPLE commands
authorJohn Darrington <john@darrington.wattle.id.au>
Wed, 17 Dec 2003 00:30:15 +0000 (00:30 +0000)
committerJohn Darrington <john@darrington.wattle.id.au>
Wed, 17 Dec 2003 00:30:15 +0000 (00:30 +0000)
tests/Makefile.am
tests/command/loop.sh [new file with mode: 0755]
tests/command/print.sh
tests/command/sample.sh
tests/loop.stat [deleted file]
tests/sample.stat [deleted file]

index 906e26d5bffa1d4e87adc5467eb09bee2ccf2185..60f81fcedb20f82288b5eec16ad9cae71a2a84be 100644 (file)
@@ -1,8 +1,5 @@
 ## Process this file with automake to produce Makefile.in  -*- makefile -*-
 
-bench:
-       make BENCHMARK=1 check
-
 TESTS_ENVIRONMENT=top_srcdir=${top_srcdir}
 TESTS = command/aggregate.sh \
        command/autorecod.sh \
@@ -12,7 +9,9 @@ TESTS = command/aggregate.sh \
        command/descriptives.sh \
        command/flip.sh \
        command/lag.sh \
+       command/loop.sh \
        command/print.sh \
+       command/sample.sh \
        command/sort.sh \
        command/tabs.sh \
        command/split-file.sh \
@@ -26,19 +25,16 @@ noinst_DATA = sort.data
 sort.data: gengarbage$(EXTEXT)
        ./gengarbage | head -1000 > $@
 
-EXTRA_DIST = bignum.data       \
-bignum.stat compute.stat count.stat crosstabs.stat data-fmts.stat      \
-data-list.data data-list.stat descript.stat do-if.stat do-repeat.stat  \
-expr.stat file-lab.stat filter.stat flip.stat gengarbage.c             \
-inpt-pgm.stat lag.stat list.data list.stat loop.stat mtch-file.stat    \
-means.stat mdfy-vars.stat print.stat pcs-if.stat recode.stat           \
-repeating.stat reread.data reread.stat sample.stat sort.stat           \
-splt-file.stat sys-info.stat t-test.stat tabs.stat temporary.stat      \
+EXTRA_DIST = \
+compute.stat crosstabs.stat data-fmts.stat     \
+data-list.data data-list.stat do-if.stat do-repeat.stat        \
+expr.stat file-lab.stat filter.stat gengarbage.c               \
+inpt-pgm.stat list.data list.stat mtch-file.stat       \
+means.stat mdfy-vars.stat pcs-if.stat recode.stat              \
+repeating.stat reread.data reread.stat  \
+sys-info.stat t-test.stat temporary.stat       \
 time-date.stat vector.stat weighting.data weighting.stat $(TESTS)
 
-dist-hook:
-       cp -rp $(srcdir)/expect $(distdir)
-
 DISTCLEANFILES = *.save sort.data pspp.* foo* msgs *.actual
 
 MAINTAINERCLEANFILES = Makefile.in
diff --git a/tests/command/loop.sh b/tests/command/loop.sh
new file mode 100755 (executable)
index 0000000..474c899
--- /dev/null
@@ -0,0 +1,93 @@
+#!/bin/sh
+
+# This program tests the LOOP command
+
+TEMPDIR=/tmp/pspp-tst-$$
+
+here=`pwd`;
+
+# ensure that top_srcdir is absolute
+cd $top_srcdir; top_srcdir=`pwd`
+
+export STAT_CONFIG_PATH=$top_srcdir/config
+
+
+cleanup()
+{
+     rm -rf $TEMPDIR
+}
+
+
+fail()
+{
+    echo $activity
+    echo FAILED
+    cleanup;
+    exit 1;
+}
+
+
+no_result()
+{
+    echo $activity
+    echo NO RESULT;
+    cleanup;
+    exit 2;
+}
+
+pass()
+{
+    cleanup;
+    exit 0;
+}
+
+mkdir -p $TEMPDIR
+
+cd $TEMPDIR
+
+activity="create prog"
+cat > $TEMPDIR/loop.stat <<EOF
+data list /x 1 y 2 z 3.
+begin data.
+125
+256
+397
+401
+end data.
+loop i=y to z by abs(z-y)/(z-y).
+print /x i.
+break.         /* Generates warning.
+end loop.
+execute.
+EOF
+if [ $? -ne 0 ] ; then no_result ; fi
+
+activity="run program"
+$here/../src/pspp --testing-mode -o raw-ascii $TEMPDIR/loop.stat > $TEMPDIR/stdout
+if [ $? -ne 0 ] ; then no_result ; fi
+
+activity="compare stdout"
+diff -B -b $TEMPDIR/stdout  - <<EOF
+$TEMPDIR/loop.stat:10: warning: BREAK: BREAK not enclosed in DO IF structure.
+EOF
+if [ $? -ne 0 ] ; then fail ; fi
+
+activity="compare results"
+diff -B -b $TEMPDIR/pspp.list  - <<EOF
+1.1 DATA LIST.  Reading 1 record from the command file.
++--------+------+-------+------+
+|Variable|Record|Columns|Format|
+#========#======#=======#======#
+|X       |     1|  1-  1|F1.0  |
+|Y       |     1|  2-  2|F1.0  |
+|Z       |     1|  3-  3|F1.0  |
++--------+------+-------+------+
+1     2.00 
+2     5.00 
+3     9.00 
+4      .00 
+EOF
+if [ $? -ne 0 ] ; then fail ; fi
+
+
+pass;
index 77daac3a24b830b36289ab774c313a64f5721ec8..f6f714e10a3587701ba59d4ff2d5f5ac36761458 100755 (executable)
@@ -52,7 +52,7 @@ if [ $? -ne 0 ] ; then no_result ; fi
 
 
 activity="create program"
-cat > $TEMPDIR/print.stat <<EOF_print
+cat > $TEMPDIR/print.stat << foobar
 title 'Test PRINT transformation'.
 
 remark EOF
@@ -81,7 +81,7 @@ data list list table file='$TEMPDIR/data-list.data'/A B C D.
 print table/A B C D.
 list.
 
-EOF_print
+foobar
 if [ $? -ne 0 ] ; then no_result ; fi
 
 
@@ -109,7 +109,6 @@ $TEMPDIR/data-list.data:6: warning: LIST: Missing value(s) for all variables fro
 EOF
 if [ $? -ne 0 ] ; then fail ; fi
 
-cp $TEMPDIR/pspp.list /tmp/out
 activity="compare output"
 diff -b -B $TEMPDIR/pspp.list - << EOF
 ----------------------------------------------------------------------
index 599892714731308d1e2ca2bc9acbb4e5cb419d0b..b5ab80e71fbee50de4f0b2fd840c5913afed97fd 100755 (executable)
@@ -48,7 +48,7 @@ cd $TEMPDIR
 
 activity="create program"
 cat > $TEMPDIR/sample.stat <<EOF
-set seed=2
+set seed=3
 
 data list /a 1-2.
 begin data.
@@ -64,16 +64,31 @@ begin data.
 10
 end data.
 sample .5.
-n 5.
 list.
 EOF
 if [ $? -ne 0 ] ; then no_result ; fi
 
 
-$here/../src/pspp -o raw-ascii $TEMPDIR/sample.stat
-if [ $? -ne 0 ] ; then fail ; fi
-
-fail
+activity="run program"
+$here/../src/pspp -o raw-ascii --testing-mode $TEMPDIR/sample.stat 
+if [ $? -ne 0 ] ; then no_result ; fi
 
+activity="compare results"
+diff -B -b $TEMPDIR/pspp.list - << EOF
+1.1 DATA LIST.  Reading 1 record from the command file.
++--------+------+-------+------+
+|Variable|Record|Columns|Format|
+#========#======#=======#======#
+|A       |     1|  1-  2|F2.0  |
++--------+------+-------+------+
+
+ A
+--
+ 2
+ 6
+ 9 
+10 
+EOF
+if [ $? -ne 0 ] ; then fail ; fi
 
 pass;
diff --git a/tests/loop.stat b/tests/loop.stat
deleted file mode 100644 (file)
index b1aa4c1..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-title 'Test LOOP procedure'.
-
-data list /x 1 y 2 z 3.
-begin data.
-125
-256
-397
-401
-end data.
-loop i=y to z by abs(z-y)/(z-y).
-print /x i.
-break.         /* Generates warning.
-end loop.
-execute.
diff --git a/tests/sample.stat b/tests/sample.stat
deleted file mode 100644 (file)
index f630391..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-
-set seed=2
-data list /a 1-2.
-begin data.
-1
-2
-3
-4
-5
-6
-7
-8
-9
-10
-end data.
-
-sample .5 .
-list.