Added a test for the WEIGHT command
authorJohn Darrington <john@darrington.wattle.id.au>
Wed, 17 Dec 2003 06:03:19 +0000 (06:03 +0000)
committerJohn Darrington <john@darrington.wattle.id.au>
Wed, 17 Dec 2003 06:03:19 +0000 (06:03 +0000)
tests/Makefile.am
tests/command/weight.sh [new file with mode: 0755]
tests/expect/weighting.stat [deleted file]
tests/weighting.stat [deleted file]

index 4c9f3f647a16c599979143b1d76e68da412075f7..201a194657b0b5e772a1552cc9578105183b1fbd 100644 (file)
@@ -18,6 +18,7 @@ TESTS = command/aggregate.sh \
        command/sort.sh \
        command/tabs.sh \
        command/split-file.sh \
+       command/weight.sh \
        bugs/double-frequency.sh \
        bugs/html-frequency.sh \
        bugs/crosstabs.sh
diff --git a/tests/command/weight.sh b/tests/command/weight.sh
new file mode 100755 (executable)
index 0000000..35bbaa7
--- /dev/null
@@ -0,0 +1,167 @@
+#!/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/weight.stat <<EOF
+data list file='$here/weighting.data'/AVAR 1-5 BVAR 6-10.
+weight by BVAR.
+
+descriptives AVAR /statistics all /format serial.
+frequencies AVAR /statistics all /format condensed.
+
+EOF
+if [ $? -ne 0 ] ; then no_result ; fi
+
+
+activity="run program"
+$here/../src/pspp --testing-mode -o raw-ascii $TEMPDIR/weight.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 file "/tmp/pspp/tests/weighting.data".
++--------+------+-------+------+
+|Variable|Record|Columns|Format|
+#========#======#=======#======#
+|AVAR    |     1|  1-  5|F5.0  |
+|BVAR    |     1|  6- 10|F5.0  |
++--------+------+-------+------+
+
+2.1(1) DESCRIPTIVES.  Valid cases = 730; cases with missing value(s) = 0.
++--------#-------+---------+------+--------+-------+--------+--------+--------+
+|Variable#Valid N|Missing N| Mean |S E Mean|Std Dev|Variance|Kurtosis|S E Kurt|
+#========#=======#=========#======#========#=======#========#========#========#
+|AVAR    #    730|        0|31.515|    .405| 10.937| 119.608|2548.162|    .181|
++--------#-------+---------+------+--------+-------+--------+--------+--------+
+
+2.1(2) DESCRIPTIVES.  Valid cases = 730; cases with missing value(s) = 0.
++--------#--------+--------+------+-------+-------+---------+
+|Variable#Skewness|S E Skew| Range|Minimum|Maximum|   Sum   |
+#========#========#========#======#=======#=======#=========#
+|AVAR    #   1.345|    .090|76.000| 18.000| 94.000|23006.000|
++--------#--------+--------+------+-------+-------+---------+
+
+3.1 FREQUENCIES.  AVAR: 
++--------+--------+---+---+
+|        |        |   |Cum|
+|  Value |  Freq  |Pct|Pct|
+#========#========#===#===#
+|      18|       1|  0|  0|
+|      19|       7|  1|  1|
+|      20|      26|  4|  5|
+|      21|      76| 10| 15|
+|      22|      57|  8| 23|
+|      23|      58|  8| 31|
+|      24|      38|  5| 36|
+|      25|      38|  5| 41|
+|      26|      30|  4| 45|
+|      27|      21|  3| 48|
+|      28|      23|  3| 51|
+|      29|      24|  3| 55|
+|      30|      23|  3| 58|
+|      31|      14|  2| 60|
+|      32|      21|  3| 63|
+|      33|      21|  3| 65|
+|      34|      14|  2| 67|
+|      35|      14|  2| 69|
+|      36|      17|  2| 72|
+|      37|      11|  2| 73|
+|      38|      16|  2| 75|
+|      39|      14|  2| 77|
+|      40|      15|  2| 79|
+|      41|      14|  2| 81|
+|      42|      14|  2| 83|
+|      43|       8|  1| 84|
+|      44|      15|  2| 86|
+|      45|      10|  1| 88|
+|      46|      12|  2| 89|
+|      47|      13|  2| 91|
+|      48|      13|  2| 93|
+|      49|       5|  1| 94|
+|      50|       5|  1| 94|
+|      51|       3|  0| 95|
+|      52|       7|  1| 96|
+|      53|       6|  1| 96|
+|      54|       2|  0| 97|
+|      55|       2|  0| 97|
+|      56|       2|  0| 97|
+|      57|       3|  0| 98|
+|      58|       1|  0| 98|
+|      59|       3|  0| 98|
+|      61|       1|  0| 98|
+|      62|       3|  0| 99|
+|      63|       1|  0| 99|
+|      64|       1|  0| 99|
+|      65|       2|  0| 99|
+|      70|       1|  0| 99|
+|      78|       1|  0|100|
+|      79|       1|  0|100|
+|      80|       1|  0|100|
+|      94|       1|  0|100|
++--------+--------+---+---+
+
+Mean         31.515
+S.E. Mean      .405
+Median         .000
+Mode           .000
+Std Dev      10.937
+Variance    119.608
+Kurtosis      2.411
+S.E. Kurt      .181
+Skewness      1.345
+S.E. Skew      .090
+Range        76.000
+Minimum      18.000
+Maximum      94.000
+Sum       23006.000
+
+EOF
+if [ $? -ne 0 ] ; then fail ; fi
+
+
+pass;
diff --git a/tests/expect/weighting.stat b/tests/expect/weighting.stat
deleted file mode 100644 (file)
index 507dedc..0000000
+++ /dev/null
@@ -1 +0,0 @@
--:6: warning: VALUE LABELS: Truncating value label to 60 characters.
diff --git a/tests/weighting.stat b/tests/weighting.stat
deleted file mode 100644 (file)
index 2611e74..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-title 'Test WEIGHT'.
-
-data list file='weighting.data'/AVAR 1-5 BVAR 6-10.
-weight by BVAR.
-value labels avar 18 'This is a value label that is really long so it takes up lots of room.'
-                  19 'flustered and flim-flammed by fields'.
-descriptives AVAR /statistics all /format serial.
-frequencies AVAR /statistics all /format condensed.