Fix TEMPORARY bug and add regression test.
authorBen Pfaff <blp@gnu.org>
Thu, 11 Mar 2004 05:22:40 +0000 (05:22 +0000)
committerBen Pfaff <blp@gnu.org>
Thu, 11 Mar 2004 05:22:40 +0000 (05:22 +0000)
src/ChangeLog
src/temporary.c
tests/ChangeLog
tests/Makefile.am
tests/bugs/temporary.sh [new file with mode: 0755]

index 8450557f341a59ae059f2b230de3bc79c3e8f119..82f9fca442594cdf65ec5851abebb635ceed4db3 100644 (file)
@@ -1,3 +1,10 @@
+Wed Mar 10 21:16:34 2004  Ben Pfaff  <blp@gnu.org>
+
+       * temporary.c: (cmd_temporary) When TEMPORARY was the first
+       transformation following the input program, if any, for some
+       reason we special-cased f_trns.  That's just wrong.  It should
+       always be set to n_trns.
+
 Tue Mar  9 23:44:40 2004  Ben Pfaff  <blp@gnu.org>
 
        * format.c: (parse_format_specifier_name) Fix brown-bag bug
index f569028a081b389b632f42babebbcf0c9596d3aa..d82461d1e97626f3d04a7d68922f85e123be4134 100644 (file)
@@ -61,10 +61,7 @@ cmd_temporary (void)
   /* Make a copy of the current dictionary. */
   temporary = 1;
   temp_dict = dict_clone (default_dict);
-  if (f_trns == n_trns)
-    temp_trns = -1;
-  else
-    temp_trns = n_trns;
+  temp_trns = n_trns;
   debug_printf (("TEMPORARY: temp_trns=%d\n", temp_trns));
 
   return lex_end_of_command ();
index f92371b1a58fef0ea415245c6a3613e29f5f94ca..562d925aa58e1083c82eb1866c5c10564113de93 100644 (file)
@@ -1,3 +1,7 @@
+Wed Mar 10 21:22:03 2004  Ben Pfaff  <blp@gnu.org>
+
+       * bugs/temporary.sh: Test that basic use of TEMPORARY works.
+
 Mon Feb 16 21:36:57 2004  Ben Pfaff  <blp@gnu.org>
 
        * */*.sh: Prepend $SUPERVISOR to invocations of pspp so that we
index c5c40adda14090fbcbd37ac2c1150aec8454fc94..5b7249df76eef49b52ae4121bd8e65dda8c34c30 100644 (file)
@@ -31,7 +31,8 @@ TESTS = command/aggregate.sh \
        bugs/html-frequency.sh \
        bugs/crosstabs.sh \
        bugs/data-crash.sh \
-       bugs/random.sh 
+       bugs/random.sh \
+       bugs/temporary.sh
 
 noinst_PROGRAMS = gengarbage
 
diff --git a/tests/bugs/temporary.sh b/tests/bugs/temporary.sh
new file mode 100755 (executable)
index 0000000..efb39ec
--- /dev/null
@@ -0,0 +1,98 @@
+#!/bin/sh
+
+# This program tests for a bug which caused UNIFORM(x) to always return zero.
+
+
+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/rnd.sps <<EOF
+DATA LIST LIST NOTABLE /x *.
+begin data.
+1
+2
+3
+4
+5
+6
+7
+8
+9
+end data.
+
+temporary.
+select if x > 5 .
+list.
+
+list.
+EOF
+if [ $? -ne 0 ] ; then no_result ; fi
+
+$SUPERVISOR $here/../src/pspp -o raw-ascii $TEMPDIR/rnd.sps
+if [ $? -ne 0 ] ; then no_result ; fi
+
+
+diff -b -B -w $TEMPDIR/pspp.list - << EOF
+       X
+--------
+    6.00 
+    7.00 
+    8.00 
+    9.00 
+
+       X
+--------
+    1.00 
+    2.00 
+    3.00 
+    4.00 
+    5.00 
+    6.00 
+    7.00 
+    8.00 
+    9.00 
+EOF
+if [ $? -ne 0 ] ; then fail ; fi
+
+pass;