From c324bad16b90b760d990697fccca863a20a54c23 Mon Sep 17 00:00:00 2001 From: John Darrington Date: Thu, 18 Dec 2003 02:12:11 +0000 Subject: [PATCH] Added a test for the FILTER command --- tests/Makefile.am | 11 +--- tests/command/filter.sh | 116 ++++++++++++++++++++++++++++++++++++++ tests/command/sys-info.sh | 104 ++++++++++++++++++++++++++++++++++ tests/filter.stat | 21 ------- 4 files changed, 222 insertions(+), 30 deletions(-) create mode 100755 tests/command/filter.sh create mode 100755 tests/command/sys-info.sh delete mode 100644 tests/filter.stat diff --git a/tests/Makefile.am b/tests/Makefile.am index 201a1946..b4a92fd2 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -9,6 +9,7 @@ TESTS = command/aggregate.sh \ command/compute.sh \ command/descriptives.sh \ command/file-label.sh \ + command/filter.sh \ command/flip.sh \ command/lag.sh \ command/list.sh \ @@ -29,15 +30,7 @@ noinst_DATA = sort.data sort.data: gengarbage$(EXTEXT) ./gengarbage | head -1000 > $@ -EXTRA_DIST = \ -crosstabs.stat data-fmts.stat \ -data-list.data do-if.stat do-repeat.stat \ -expr.stat filter.stat gengarbage.c \ -inpt-pgm.stat list.data 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) +EXTRA_DIST = $(TESTS) DISTCLEANFILES = *.save sort.data pspp.* foo* msgs *.actual diff --git a/tests/command/filter.sh b/tests/command/filter.sh new file mode 100755 index 00000000..180b59f6 --- /dev/null +++ b/tests/command/filter.sh @@ -0,0 +1,116 @@ +#!/bin/sh + +# This program tests .... + +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 program" +cat > $TEMPDIR/filter.stat << EOF +data list notable /x 1-2. +begin data. +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +end data. +compute filter_$ = mod(x,2). + +filter by filter_$. +list. +filter off. +list. +compute filter_$ = 1 - filter_$. +filter by filter_$. +list. + +EOF +if [ $? -ne 0 ] ; then no_result ; fi + + +activity="run program" +$here/../src/pspp --testing-mode -o raw-ascii $TEMPDIR/filter.stat +if [ $? -ne 0 ] ; then no_result ; fi + + +activity="check results" +diff -B -b $TEMPDIR/pspp.list - << EOF + X FILTER_$ +-- -------- + 1 1.00 + 3 1.00 + 5 1.00 + 7 1.00 + 9 1.00 + + X FILTER_$ +-- -------- + 1 1.00 + 2 .00 + 3 1.00 + 4 .00 + 5 1.00 + 6 .00 + 7 1.00 + 8 .00 + 9 1.00 +10 .00 + + X FILTER_$ +-- -------- + 2 1.00 + 4 1.00 + 6 1.00 + 8 1.00 +10 1.00 + +EOF +if [ $? -ne 0 ] ; then fail ; fi + +pass; diff --git a/tests/command/sys-info.sh b/tests/command/sys-info.sh new file mode 100755 index 00000000..35a64c87 --- /dev/null +++ b/tests/command/sys-info.sh @@ -0,0 +1,104 @@ +#!/bin/sh + +# This program tests the SYSFILE INFO 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 program 1" +cat > $TEMPDIR/save.stat << EOF +data list /x 1-2. +begin data. +3 +34 +2 +98 +end data. +save 'foo.save'. +display $JDATE. +finish. +EOF +if [ $? -ne 0 ] ; then no_result ; fi +cp $TEMPDIR/pspp.list /tmp/bar + +activity="run program 1" +$here/../src/pspp --testing-mode -o raw-ascii $TEMPDIR/save.stat +if [ $? -ne 0 ] ; then no_result ; fi + +activity="create program 2" +cat > $TEMPDIR/read.stat << EOF +sysfile info file='foo.save'. + +finish. +EOF +if [ $? -ne 0 ] ; then no_result ; fi + +activity="run program 2" +$here/../src/pspp --testing-mode -o raw-ascii $TEMPDIR/read.stat +if [ $? -ne 0 ] ; then no_result ; fi + + +activity="compare output" +diff -B -b $TEMPDIR/pspp.list - << EOF +1.1 SYSFILE INFO. +File: $TEMPDIR/foo.save +Label: No label. +Created: 18 Dec 03 09:05:20 by GNU pspp 0.3.1 - i686-pc-cygwin +Endian: Little. +Variables: 1 +Cases: 4 +Type: System File. +Weight: Not weighted. +Mode: Compression on. ++--------+-------------+---+ +|Variable|Description |Pos| +| | |iti| +| | |on | +#========#=============#===# +|X |Format: F2.0 | 1| ++--------+-------------+---+ +EOF +if [ $? -ne 0 ] ; then fail ; fi + + +pass; diff --git a/tests/filter.stat b/tests/filter.stat deleted file mode 100644 index 3761e387..00000000 --- a/tests/filter.stat +++ /dev/null @@ -1,21 +0,0 @@ -title 'Test FILTER'. - -data list /x 1-2. -begin data. -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -end data. -compute filter_$ = mod(x,2). -filter by filter_$. -list. -compute filter_$ = 1 - filter_$. -list. - -- 2.30.2