From: John Darrington <john@darrington.wattle.id.au> Date: Tue, 16 Dec 2003 02:57:32 +0000 (+0000) Subject: Added tests for descriptives and flip X-Git-Tag: v0.4.0~449 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7ee0b85d700d99fc3cba91c37da31e3d01ac0f47;p=pspp-builds.git Added tests for descriptives and flip --- diff --git a/tests/Makefile.am b/tests/Makefile.am index 402a22ea..2d2cf71c 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -9,6 +9,8 @@ TESTS = command/aggregate.sh \ command/beg-data.sh \ command/bignum.sh \ command/count.sh \ + command/descriptives.sh \ + command/flip.sh \ command/sort.sh \ bugs/double-frequency.sh \ bugs/html-frequency.sh diff --git a/tests/command/bignum.sh b/tests/command/bignum.sh new file mode 100755 index 00000000..17cc5519 --- /dev/null +++ b/tests/command/bignum.sh @@ -0,0 +1,156 @@ +#!/bin/sh + +# This program tests the use of big numbers + +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 data file" +cat > $TEMPDIR/bignum.data << wizzah +0 +0.1 +0.5 +0.8 +0.9 +0.999 +1 +2 +3 +4 +5 +12 +123 +1234 +12345 +123456 +1234567 +12345678 +123456789 +1234567890 +19999999999 +199999999999 +1234567890123 +19999999999999 +199999999999999 +1234567890123456 +19999999999999999 +123456789012345678 +1999999999999999999 +12345678901234567890 +199999999999999999999 +1234567890123456789012 +19999999999999999999999 +123456789012345678901234 +1999999999999999999999999 +12345678901234567890123456 +199999999999999999999999999 +1234567890123456789012345678 +19999999999999999999999999999 +123456789012345678901234567890 +1999999999999999999999999999999 +12345678901234567890123456789012 +199999999999999999999999999999999 +1234567890123456789012345678901234 +19999999999999999999999999999999999 +123456789012345678901234567890123456 +1999999999999999999999999999999999999 +12345678901234567890123456789012345678 +199999999999999999999999999999999999999 +1234567890123456789012345678901234567890 +1999999999999999999999999999999999999999 +1e40 +1.1e40 +1.5e40 +1e41 +1e50 +1e100 +1e150 +1e200 +1e250 +1e300 +1.79641e308 +wizzah +if [ $? -ne 0 ] ; then no_result ; fi + + +activity="create program" +cat > $TEMPDIR/prog.stat <<foobar +title 'Test use of big numbers'. + +*** Do the portable output. +remark EOF +---------------------------------------------------------------------- +Testing use of big numbers.\n +The numbers in the data file are designed for IEEE754 double +format--if your system uses something different then the test needs to +be adjusted for whatever are big numbers to your system. +---------------------------------------------------------------------- +EOF +data list file='$TEMPDIR/bignum.data'/BIGNUM 1-40. +list. + +*** Do the nonportable output for fun. +remark EOF +NOCOMP +SUCCESS? +---------------------------------------------------------------------- +This test merely shows whether your system can successfully handle +floating-point overflow. If you get a fatal exception at this point, +the source needs some editing--glob.c should mask overflow exceptions +in init_glob(). Again, the numbers are specific to IEEE754 double +format. +---------------------------------------------------------------------- +EOF +descriptives BIGNUM. +rem-SUCCESS +foobar +if [ $? -ne 0 ] ; then no_result ; fi + +activity="run program" +$here/../src/pspp -o raw-ascii prog.stat +if [ $? -ne 0 ] ; then no_result ; fi + +# Like the above comments say ... +# ... if we get here without crashing, then the test has passed. + +pass; diff --git a/tests/command/count.sh b/tests/command/count.sh new file mode 100755 index 00000000..345e2527 --- /dev/null +++ b/tests/command/count.sh @@ -0,0 +1,95 @@ +#!/bin/sh + +# This program tests the count transformation + +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 + +cat > $TEMPDIR/count.stat <<EOF +title 'Test COUNT transformation'. + +* we're going to count the 2s 4s and 1s in the data +data list /v1 to v2 1-4(a). +begin data. +1234 +321 <---- +2 13 <---- +4121 +1104 ---- this is not '4', but '04' (v1 and v2 are string format ) +03 4 <---- +0193 +end data. +count c=v1 to v2('2',' 4','1'). +list. +EOF +if [ $? -ne 0 ] ; then no_result ; fi + + +$here/../src/pspp -o raw-ascii $TEMPDIR/count.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| +#========#======#=======#======# +|V1 | 1| 1- 2|A2 | +|V2 | 1| 3- 4|A2 | ++--------+------+-------+------+ + +V1 V2 C +-- -- -------- +12 34 .00 +32 1 1.00 +2 13 1.00 +41 21 .00 +11 04 .00 +03 4 1.00 +01 93 .00 +EOF +if [ $? -ne 0 ] ; then no_result ; fi + + +pass; diff --git a/tests/command/descriptives.sh b/tests/command/descriptives.sh new file mode 100755 index 00000000..b19c9ce2 --- /dev/null +++ b/tests/command/descriptives.sh @@ -0,0 +1,151 @@ +#!/bin/sh + +# This program tests that the descriptives command actually works + +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/descript.stat <<EOF +title 'Test DESCRIPTIVES procedure'. + +data list / v0 to v16 1-17. +begin data. +12128989012389023 +34128080123890128 +56127781237893217 +78127378123793112 +90913781237892318 +37978547878935789 +52878237892378279 +12377912789378932 +26787654347894348 +29137178947891888 +end data. + +descript all/stat=all/format=serial. + +EOF +if [ $? -ne 0 ] ; then no_result ; fi + + +activity="run program" +$here/../src/pspp -o raw-ascii $TEMPDIR/descript.stat +if [ $? -ne 0 ] ; then no_result ; fi + + +activity="compare output" +diff -B -b $TEMPDIR/pspp.list - <<EOF +1.1 DATA LIST. Reading 1 record from the command file. ++--------+------+-------+------+ +|Variable|Record|Columns|Format| +#========#======#=======#======# +|V0 | 1| 1- 1|F1.0 | +|V1 | 1| 2- 2|F1.0 | +|V2 | 1| 3- 3|F1.0 | +|V3 | 1| 4- 4|F1.0 | +|V4 | 1| 5- 5|F1.0 | +|V5 | 1| 6- 6|F1.0 | +|V6 | 1| 7- 7|F1.0 | +|V7 | 1| 8- 8|F1.0 | +|V8 | 1| 9- 9|F1.0 | +|V9 | 1| 10- 10|F1.0 | +|V10 | 1| 11- 11|F1.0 | +|V11 | 1| 12- 12|F1.0 | +|V12 | 1| 13- 13|F1.0 | +|V13 | 1| 14- 14|F1.0 | +|V14 | 1| 15- 15|F1.0 | +|V15 | 1| 16- 16|F1.0 | +|V16 | 1| 17- 17|F1.0 | ++--------+------+-------+------+ + +2.1(1) DESCRIPTIVES. Valid cases = 10; cases with missing value(s) = 0. ++--------#-------+---------+-----+--------+-------+--------+--------+--------+ +|Variable#Valid N|Missing N| Mean|S E Mean|Std Dev|Variance|Kurtosis|S E Kurt| +#========#=======#=========#=====#========#=======#========#========#========# +|V0 # 10| 0|3.800| .841| 2.658| 7.067| -.035| 1.334| +|V1 # 10| 0|4.600| .957| 3.026| 9.156| -1.386| 1.334| +|V2 # 10| 0|4.100| 1.159| 3.665| 13.433| -2.019| 1.334| +|V3 # 10| 0|4.100| .875| 2.767| 7.656| -2.049| 1.334| +|V4 # 10| 0|7.000| .471| 1.491| 2.222| 7.152| 1.334| +|V5 # 10| 0|4.900| 1.027| 3.247| 10.544| -1.401| 1.334| +|V6 # 10| 0|5.900| .795| 2.514| 6.322| -.290| 1.334| +|V7 # 10| 0|4.700| 1.096| 3.466| 12.011| -1.993| 1.334| +|V8 # 10| 0|4.100| 1.100| 3.479| 12.100| -1.928| 1.334| +|V9 # 10| 0|4.300| .870| 2.751| 7.567| -.875| 1.334| +|V10 # 10| 0|5.500| .847| 2.677| 7.167| -1.842| 1.334| +|V11 # 10| 0|6.500| .778| 2.461| 6.056| -1.276| 1.334| +|V12 # 10| 0|7.900| .605| 1.912| 3.656| 5.241| 1.334| +|V13 # 10| 0|4.300| .989| 3.129| 9.789| -1.248| 1.334| +|V14 # 10| 0|3.600| 1.013| 3.204| 10.267| -.961| 1.334| +|V15 # 10| 0|3.700| .920| 2.908| 8.456| -1.352| 1.334| +|V16 # 10| 0|6.400| .909| 2.875| 8.267| -1.142| 1.334| ++--------#-------+---------+-----+--------+-------+--------+--------+--------+ + +2.1(2) DESCRIPTIVES. Valid cases = 10; cases with missing value(s) = 0. ++--------#--------+--------+-----+-------+-------+------+ +|Variable#Skewness|S E Skew|Range|Minimum|Maximum| Sum | +#========#========#========#=====#=======#=======#======# +|V0 # .889| .687|8.000| 1.000| 9.000|38.000| +|V1 # -.032| .687|9.000| .000| 9.000|46.000| +|V2 # .476| .687|8.000| 1.000| 9.000|41.000| +|V3 # .422| .687|7.000| 1.000| 8.000|41.000| +|V4 # -2.516| .687|5.000| 3.000| 8.000|70.000| +|V5 # -.205| .687|9.000| .000| 9.000|49.000| +|V6 # -.960| .687|7.000| 1.000| 8.000|59.000| +|V7 # -.165| .687|9.000| .000| 9.000|47.000| +|V8 # .371| .687|9.000| .000| 9.000|41.000| +|V9 # .730| .687|8.000| 1.000| 9.000|43.000| +|V10 # -.326| .687|7.000| 2.000| 9.000|55.000| +|V11 # -.895| .687|6.000| 3.000| 9.000|65.000| +|V12 # -2.208| .687|6.000| 3.000| 9.000|79.000| +|V13 # .333| .687|9.000| .000| 9.000|43.000| +|V14 # .809| .687|9.000| .000| 9.000|36.000| +|V15 # .710| .687|7.000| 1.000| 8.000|37.000| +|V16 # -.923| .687|7.000| 2.000| 9.000|64.000| ++--------#--------+--------+-----+-------+-------+------+ +EOF +if [ $? -ne 0 ] ; then fail ; fi + + +pass \ No newline at end of file diff --git a/tests/command/flip.sh b/tests/command/flip.sh new file mode 100755 index 00000000..759c4fd0 --- /dev/null +++ b/tests/command/flip.sh @@ -0,0 +1,110 @@ +#!/bin/sh + +# This program tests the flip 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 flip.stat" +cat > $TEMPDIR/flip.stat <<EOF +data list /n 1 (a) a b c d 2-9. +list. +begin data. +v 1 2 3 4 5 +w 6 7 8 910 +x1112131415 +y1617181920 +z2122232425 +end data. +flip newnames=n. +list. +flip. +list. +EOF +if [ $? -ne 0 ] ; then no_result ; fi + + +activity="run program" +$here/../src/pspp -o raw-ascii $TEMPDIR/flip.stat +if [ $? -ne 0 ] ; then no_result ; fi + +activity="compare output" +diff -b -B $TEMPDIR/pspp.list - << EOF +1.1 DATA LIST. Reading 1 record from the command file. ++--------+------+-------+------+ +|Variable|Record|Columns|Format| +#========#======#=======#======# +|N | 1| 1- 1|A1 | +|A | 1| 2- 3|F2.0 | +|B | 1| 4- 5|F2.0 | +|C | 1| 6- 7|F2.0 | +|D | 1| 8- 9|F2.0 | ++--------+------+-------+------+ + +N A B C D +- -- -- -- -- +v 1 2 3 4 +w 6 7 8 9 +x 11 12 13 14 +y 16 17 18 19 +z 21 22 23 24 + +CASE_LBL V W X Y Z +-------- -------- -------- -------- -------- -------- +A 1.00 6.00 11.00 16.00 21.00 +B 2.00 7.00 12.00 17.00 22.00 +C 3.00 8.00 13.00 18.00 23.00 +D 4.00 9.00 14.00 19.00 24.00 + +CASE_LBL A B C D +-------- -------- -------- -------- -------- +V 1.00 2.00 3.00 4.00 +W 6.00 7.00 8.00 9.00 +X 11.00 12.00 13.00 14.00 +Y 16.00 17.00 18.00 19.00 +Z 21.00 22.00 23.00 24.00 +EOF +if [ $? -ne 0 ] ; then fail ; fi + + +pass; diff --git a/tests/descript.stat b/tests/descript.stat deleted file mode 100644 index 334ea2b4..00000000 --- a/tests/descript.stat +++ /dev/null @@ -1,17 +0,0 @@ -title 'Test DESCRIPTIVES procedure'. - -data list / v0 to v16 1-17. -begin data. -12128989012389023 -34128080123890128 -56127781237893217 -78127378123793112 -90913781237892318 -37978547878935789 -52878237892378279 -12377912789378932 -26787654347894348 -29137178947891888 -end data. - -descript all/stat=all/format=serial. diff --git a/tests/flip.stat b/tests/flip.stat deleted file mode 100644 index e1ee8bed..00000000 --- a/tests/flip.stat +++ /dev/null @@ -1,13 +0,0 @@ -data list /n 1 (a) a b c d 2-9. -list. -begin data. -v 1 2 3 4 5 -w 6 7 8 910 -x1112131415 -y1617181920 -z2122232425 -end data. -flip newnames=n. -list. -flip. -list.