[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pspp-cvs] pspp doc/data-io.texi src/language/control/Chan...
From: |
Ben Pfaff |
Subject: |
[Pspp-cvs] pspp doc/data-io.texi src/language/control/Chan... |
Date: |
Sun, 23 Sep 2007 16:47:29 +0000 |
CVSROOT: /cvsroot/pspp
Module name: pspp
Changes by: Ben Pfaff <blp> 07/09/23 16:47:28
Modified files:
doc : data-io.texi
src/language/control: ChangeLog do-if.c
src/language/data-io: ChangeLog data-list.c
tests : ChangeLog automake.mk
Added files:
tests/command : do-if.sh input-program.sh
Log message:
Bug #21111. Reviewed by John Darrington.
* command/input-program.sh: New test.
* command/do-if.sh: New tests.
* data-list.c (data_list_trns_proc): Properly set retval when END
subcommand is in use.
* do-if.c: Fix ELSE and ELSE IF clauses.
(add_clause): Drop TARGET_INDEX argument and figure out the target
of the jump on our own. The caller couldn't compensate for the
inserted BREAK transformation. Updated all callers.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pspp/doc/data-io.texi?cvsroot=pspp&r1=1.14&r2=1.15
http://cvs.savannah.gnu.org/viewcvs/pspp/src/language/control/ChangeLog?cvsroot=pspp&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/pspp/src/language/control/do-if.c?cvsroot=pspp&r1=1.15&r2=1.16
http://cvs.savannah.gnu.org/viewcvs/pspp/src/language/data-io/ChangeLog?cvsroot=pspp&r1=1.46&r2=1.47
http://cvs.savannah.gnu.org/viewcvs/pspp/src/language/data-io/data-list.c?cvsroot=pspp&r1=1.34&r2=1.35
http://cvs.savannah.gnu.org/viewcvs/pspp/tests/ChangeLog?cvsroot=pspp&r1=1.110&r2=1.111
http://cvs.savannah.gnu.org/viewcvs/pspp/tests/automake.mk?cvsroot=pspp&r1=1.39&r2=1.40
http://cvs.savannah.gnu.org/viewcvs/pspp/tests/command/do-if.sh?cvsroot=pspp&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/pspp/tests/command/input-program.sh?cvsroot=pspp&rev=1.1
Patches:
Index: doc/data-io.texi
===================================================================
RCS file: /cvsroot/pspp/pspp/doc/data-io.texi,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- doc/data-io.texi 16 Sep 2007 02:41:14 -0000 1.14
+++ doc/data-io.texi 23 Sep 2007 16:47:27 -0000 1.15
@@ -541,6 +541,8 @@
All this is very confusing. A few examples should help to clarify.
address@hidden If you change this example, change the regression test1 in
address@hidden tests/command/input-program.sh to match.
@example
INPUT PROGRAM.
DATA LIST NOTABLE FILE='a.data'/X 1-10.
@@ -553,6 +555,8 @@
Y from file @file{b.data}. If one file is shorter than the other then
the extra data in the longer file is ignored.
address@hidden If you change this example, change the regression test2 in
address@hidden tests/command/input-program.sh to match.
@example
INPUT PROGRAM.
NUMERIC #A #B.
@@ -576,6 +580,8 @@
field is set to the system-missing value alongside the present value for
the remaining length of the longer file.
address@hidden If you change this example, change the regression test3 in
address@hidden tests/command/input-program.sh to match.
@example
INPUT PROGRAM.
NUMERIC #A #B.
@@ -600,6 +606,8 @@
The above example reads data from file @file{a.data}, then from
@file{b.data}, and concatenates them into a single active file.
address@hidden If you change this example, change the regression test4 in
address@hidden tests/command/input-program.sh to match.
@example
INPUT PROGRAM.
NUMERIC #EOF.
@@ -627,6 +635,8 @@
The above example does the same thing as the previous example, in a
different way.
address@hidden If you change this example, make similar changes to the
regression
address@hidden test5 in tests/command/input-program.sh.
@example
INPUT PROGRAM.
LOOP #I=1 TO 50.
Index: src/language/control/ChangeLog
===================================================================
RCS file: /cvsroot/pspp/pspp/src/language/control/ChangeLog,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- src/language/control/ChangeLog 2 Feb 2007 13:50:16 -0000 1.9
+++ src/language/control/ChangeLog 23 Sep 2007 16:47:27 -0000 1.10
@@ -1,3 +1,12 @@
+2007-09-23 Ben Pfaff <address@hidden>
+
+ Bug #21111. Reviewed by John Darrington.
+
+ * do-if.c: Fix ELSE and ELSE IF clauses.
+ (add_clause): Drop TARGET_INDEX argument and figure out the target
+ of the jump on our own. The caller couldn't compensate for the
+ inserted BREAK transformation. Updated all callers.
+
Fri Feb 2 22:41:43 WST 2007 John Darrington <address@hidden>
* repeat.c (parse_numbers): Fixed bug parseing ranges vs. lists.
Index: src/language/control/do-if.c
===================================================================
RCS file: /cvsroot/pspp/pspp/src/language/control/do-if.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- src/language/control/do-if.c 7 Jul 2007 06:14:12 -0000 1.15
+++ src/language/control/do-if.c 23 Sep 2007 16:47:27 -0000 1.16
@@ -82,8 +82,7 @@
static const struct ctl_class do_if_class;
static int parse_clause (struct lexer *, struct do_if_trns *, struct dataset
*ds);
-static void add_clause (struct do_if_trns *,
- struct expression *condition, int target_index);
+static void add_clause (struct do_if_trns *, struct expression *condition);
static void add_else (struct do_if_trns *);
static bool has_else (struct do_if_trns *);
@@ -165,7 +164,7 @@
add_else (struct do_if_trns *do_if)
{
assert (!has_else (do_if));
- add_clause (do_if, NULL, next_transformation (do_if->ds));
+ add_clause (do_if, NULL);
}
/* Returns true if DO_IF does not yet have an ELSE clause.
@@ -203,16 +202,16 @@
if (condition == NULL)
return CMD_CASCADING_FAILURE;
- add_clause (do_if, condition, next_transformation (ds));
+ add_clause (do_if, condition);
return lex_end_of_command (lexer);
}
/* Adds a clause to DO_IF that tests for the given CONDITION and,
- if true, jumps to TARGET_INDEX. */
+ if true, jumps to the set of transformations produced by
+ following commands. */
static void
-add_clause (struct do_if_trns *do_if,
- struct expression *condition, int target_index)
+add_clause (struct do_if_trns *do_if, struct expression *condition)
{
struct clause *clause;
@@ -223,7 +222,7 @@
do_if->clause_cnt + 1, sizeof *do_if->clauses);
clause = &do_if->clauses[do_if->clause_cnt++];
clause->condition = condition;
- clause->target_index = target_index;
+ clause->target_index = next_transformation (do_if->ds);
}
/* Finalizes DO IF by clearing the control stack, thus ensuring
Index: src/language/data-io/ChangeLog
===================================================================
RCS file: /cvsroot/pspp/pspp/src/language/data-io/ChangeLog,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -b -r1.46 -r1.47
--- src/language/data-io/ChangeLog 12 Sep 2007 13:43:50 -0000 1.46
+++ src/language/data-io/ChangeLog 23 Sep 2007 16:47:28 -0000 1.47
@@ -1,3 +1,10 @@
+2007-09-23 Ben Pfaff <address@hidden>
+
+ Bug #21111. Reviewed by John Darrington.
+
+ * data-list.c (data_list_trns_proc): Properly set retval when END
+ subcommand is in use.
+
2007-09-12 Ben Pfaff <address@hidden>
* get.c (get_translate_case): Change input case parameter from
Index: src/language/data-io/data-list.c
===================================================================
RCS file: /cvsroot/pspp/pspp/src/language/data-io/data-list.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -b -r1.34 -r1.35
--- src/language/data-io/data-list.c 26 Jul 2007 01:52:04 -0000 1.34
+++ src/language/data-io/data-list.c 23 Sep 2007 16:47:28 -0000 1.35
@@ -807,10 +807,10 @@
if (dls->end != NULL)
{
double *end = &case_data_rw (c, dls->end)->f;
- if (retval == TRNS_DROP_CASE)
+ if (retval == TRNS_END_FILE)
{
*end = 1.0;
- retval = TRNS_END_FILE;
+ retval = TRNS_CONTINUE;
}
else
*end = 0.0;
Index: tests/ChangeLog
===================================================================
RCS file: /cvsroot/pspp/pspp/tests/ChangeLog,v
retrieving revision 1.110
retrieving revision 1.111
diff -u -b -r1.110 -r1.111
--- tests/ChangeLog 23 Sep 2007 05:59:03 -0000 1.110
+++ tests/ChangeLog 23 Sep 2007 16:47:28 -0000 1.111
@@ -1,3 +1,11 @@
+2007-09-23 Ben Pfaff <address@hidden>
+
+ Bug #21111. Reviewed by John Darrington.
+
+ * command/input-program.sh: New test.
+
+ * command/do-if.sh: New tests.
+
2007-09-22 Ben Pfaff <address@hidden>
Bug #21128. Reviewed by John Darrington.
Index: tests/automake.mk
===================================================================
RCS file: /cvsroot/pspp/pspp/tests/automake.mk,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -b -r1.39 -r1.40
--- tests/automake.mk 23 Sep 2007 05:59:03 -0000 1.39
+++ tests/automake.mk 23 Sep 2007 16:47:28 -0000 1.40
@@ -10,6 +10,7 @@
tests/command/count.sh \
tests/command/datasheet.sh \
tests/command/data-list.sh \
+ tests/command/do-if.sh \
tests/command/do-repeat.sh \
tests/command/erase.sh \
tests/command/examine.sh \
@@ -20,6 +21,7 @@
tests/command/filter.sh \
tests/command/flip.sh \
tests/command/import-export.sh \
+ tests/command/input-program.sh \
tests/command/insert.sh \
tests/command/lag.sh \
tests/command/list.sh \
Index: tests/command/do-if.sh
===================================================================
RCS file: tests/command/do-if.sh
diff -N tests/command/do-if.sh
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/command/do-if.sh 23 Sep 2007 16:47:28 -0000 1.1
@@ -0,0 +1,115 @@
+#!/bin/sh
+
+# This program tests the DO IF command.
+
+TEMPDIR=/tmp/pspp-tst-$$
+
+# ensure that top_builddir are absolute
+if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
+if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
+top_builddir=`cd $top_builddir; pwd`
+PSPP=$top_builddir/src/ui/terminal/pspp
+
+# ensure that top_srcdir is absolute
+top_srcdir=`cd $top_srcdir; pwd`
+
+STAT_CONFIG_PATH=$top_srcdir/config
+export STAT_CONFIG_PATH
+
+LANG=C
+export LANG
+
+cleanup()
+{
+ cd /
+ #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="generate input and expected output"
+(for a in 0 1 ' '; do
+ for b in 0 1 ' '; do
+ for c in 0 1 ' '; do
+ for d in 0 1 ' '; do
+ abcd=$a$b$c$d
+ echo "$abcd" 1>&3
+ if test "$a" = "1"; then
+ echo " $abcd A"
+ elif test "$a" = " "; then
+ :
+ elif test "$b" = "1"; then
+ echo " $abcd B"
+ elif test "$b" = " "; then
+ :
+ elif test "$c" = "1"; then
+ echo " $abcd C"
+ elif test "$c" = " "; then
+ :
+ elif test "$d" = "1"; then
+ echo " $abcd D"
+ elif test "$d" = " "; then
+ :
+ else
+ echo " $abcd E"
+ fi
+ done
+ done
+ done
+done) >test1.expected 3>test1.data
+if [ $? -ne 0 ] ; then no_result ; fi
+
+activity="create test1.pspp"
+cat > test1.pspp <<EOF
+DATA LIST FILE="test1.data"/A B C D 1-4 ABCD 1-4 (A).
+DO IF A.
+PRINT OUTFILE="test1.out"/ABCD 'A'.
+ELSE IF B.
+PRINT OUTFILE="test1.out"/ABCD 'B'.
+ELSE IF C.
+PRINT OUTFILE="test1.out"/ABCD 'C'.
+ELSE IF D.
+PRINT OUTFILE="test1.out"/ABCD 'D'.
+ELSE.
+PRINT OUTFILE="test1.out"/ABCD 'E'.
+END IF.
+EXECUTE.
+EOF
+if [ $? -ne 0 ] ; then no_result ; fi
+
+activity="run test1"
+$SUPERVISOR $PSPP --testing-mode test1.pspp
+if [ $? -ne 0 ] ; then no_result ; fi
+
+activity="compare test1 results"
+perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
+diff -u $TEMPDIR/test1.out $TEMPDIR/test1.expected
+if [ $? -ne 0 ] ; then fail ; fi
+
+pass
Index: tests/command/input-program.sh
===================================================================
RCS file: tests/command/input-program.sh
diff -N tests/command/input-program.sh
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/command/input-program.sh 23 Sep 2007 16:47:28 -0000 1.1
@@ -0,0 +1,306 @@
+#!/bin/sh
+
+# This program tests the INPUT PROGRAM command, specifically all of
+# the examples given in the user manual.
+
+TEMPDIR=/tmp/pspp-tst-$$
+
+# ensure that top_builddir are absolute
+if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
+if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
+top_builddir=`cd $top_builddir; pwd`
+PSPP=$top_builddir/src/ui/terminal/pspp
+
+# ensure that top_srcdir is absolute
+top_srcdir=`cd $top_srcdir; pwd`
+
+STAT_CONFIG_PATH=$top_srcdir/config
+export STAT_CONFIG_PATH
+
+LANG=C
+export LANG
+
+cleanup()
+{
+ cd /
+ 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 a.data"
+cat > a.data <<EOF
+1
+2
+3
+EOF
+if [ $? -ne 0 ] ; then no_result ; fi
+
+activity="create b.data"
+cat > b.data <<EOF
+4
+5
+6
+7
+8
+EOF
+if [ $? -ne 0 ] ; then no_result ; fi
+
+activity="create test1.pspp"
+cat > test1.pspp <<EOF
+INPUT PROGRAM.
+ DATA LIST NOTABLE FILE='a.data'/X 1-10.
+ DATA LIST NOTABLE FILE='b.data'/Y 1-10.
+END INPUT PROGRAM.
+LIST.
+EOF
+if [ $? -ne 0 ] ; then no_result ; fi
+
+activity="run test1"
+$SUPERVISOR $PSPP --testing-mode test1.pspp
+if [ $? -ne 0 ] ; then no_result ; fi
+
+activity="compare test1 results"
+perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
+diff -b $TEMPDIR/pspp.list - << EOF
+ X Y
+---------- ----------
+ 1 4
+ 2 5
+ 3 6
+EOF
+if [ $? -ne 0 ] ; then fail ; fi
+
+activity="create test2.pspp"
+cat > test2.pspp <<EOF
+INPUT PROGRAM.
+ NUMERIC #A #B.
+
+ DO IF NOT #A.
+ DATA LIST NOTABLE END=#A FILE='a.data'/X 1-10.
+ END IF.
+ DO IF NOT #B.
+ DATA LIST NOTABLE END=#B FILE='b.data'/Y 1-10.
+ END IF.
+ DO IF #A AND #B.
+ END FILE.
+ END IF.
+ END CASE.
+END INPUT PROGRAM.
+LIST.
+EOF
+if [ $? -ne 0 ] ; then no_result ; fi
+
+activity="run test2"
+$SUPERVISOR $PSPP --testing-mode test2.pspp
+if [ $? -ne 0 ] ; then no_result ; fi
+
+activity="compare test2 results"
+perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
+diff -b $TEMPDIR/pspp.list - << EOF
+ X Y
+---------- ----------
+ 1 4
+ 2 5
+ 3 6
+ . 7
+ . 8
+EOF
+if [ $? -ne 0 ] ; then fail ; fi
+
+activity="create test3.pspp"
+cat > test3.pspp <<EOF
+INPUT PROGRAM.
+ NUMERIC #A #B.
+
+ DO IF #A.
+ DATA LIST NOTABLE END=#B FILE='b.data'/X 1-10.
+ DO IF #B.
+ END FILE.
+ ELSE.
+ END CASE.
+ END IF.
+ ELSE.
+ DATA LIST NOTABLE END=#A FILE='a.data'/X 1-10.
+ DO IF NOT #A.
+ END CASE.
+ END IF.
+ END IF.
+END INPUT PROGRAM.
+LIST.
+EOF
+if [ $? -ne 0 ] ; then no_result ; fi
+
+activity="run test3"
+$SUPERVISOR $PSPP --testing-mode test3.pspp
+if [ $? -ne 0 ] ; then no_result ; fi
+
+activity="compare test3 results"
+perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
+diff -b $TEMPDIR/pspp.list - << EOF
+ X
+----------
+ 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+EOF
+if [ $? -ne 0 ] ; then fail ; fi
+
+activity="create test4.pspp"
+cat > test4.pspp <<EOF
+INPUT PROGRAM.
+ NUMERIC #EOF.
+
+ LOOP IF NOT #EOF.
+ DATA LIST NOTABLE END=#EOF FILE='a.data'/X 1-10.
+ DO IF NOT #EOF.
+ END CASE.
+ END IF.
+ END LOOP.
+
+ COMPUTE #EOF = 0.
+ LOOP IF NOT #EOF.
+ DATA LIST NOTABLE END=#EOF FILE='b.data'/X 1-10.
+ DO IF NOT #EOF.
+ END CASE.
+ END IF.
+ END LOOP.
+
+ END FILE.
+END INPUT PROGRAM.
+LIST.
+EOF
+if [ $? -ne 0 ] ; then no_result ; fi
+
+activity="run test4"
+$SUPERVISOR $PSPP --testing-mode test4.pspp
+if [ $? -ne 0 ] ; then no_result ; fi
+
+activity="compare test4 results"
+perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
+diff -b $TEMPDIR/pspp.list - << EOF
+ X
+----------
+ 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+EOF
+if [ $? -ne 0 ] ; then fail ; fi
+
+# This example differs slightly from the one in the manual in that
+# it doesn't generate random variates. There's already a test that
+# checks that random variates are predictable, so we don't need
+# another.
+activity="create test5.pspp"
+cat > test5.pspp <<EOF
+INPUT PROGRAM.
+ LOOP #I=1 TO 50.
+ COMPUTE X=#I * 3.
+ END CASE.
+ END LOOP.
+ END FILE.
+END INPUT PROGRAM.
+LIST/FORMAT=NUMBERED.
+EOF
+if [ $? -ne 0 ] ; then no_result ; fi
+
+activity="run test5"
+$SUPERVISOR $PSPP --testing-mode test5.pspp
+if [ $? -ne 0 ] ; then no_result ; fi
+
+activity="compare test5 results"
+perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
+diff -b $TEMPDIR/pspp.list - << EOF
+Case# X
+----- --------
+ 1 3.00
+ 2 6.00
+ 3 9.00
+ 4 12.00
+ 5 15.00
+ 6 18.00
+ 7 21.00
+ 8 24.00
+ 9 27.00
+ 10 30.00
+ 11 33.00
+ 12 36.00
+ 13 39.00
+ 14 42.00
+ 15 45.00
+ 16 48.00
+ 17 51.00
+ 18 54.00
+ 19 57.00
+ 20 60.00
+ 21 63.00
+ 22 66.00
+ 23 69.00
+ 24 72.00
+ 25 75.00
+ 26 78.00
+ 27 81.00
+ 28 84.00
+ 29 87.00
+ 30 90.00
+ 31 93.00
+ 32 96.00
+ 33 99.00
+ 34 102.00
+ 35 105.00
+ 36 108.00
+ 37 111.00
+ 38 114.00
+ 39 117.00
+ 40 120.00
+ 41 123.00
+ 42 126.00
+ 43 129.00
+ 44 132.00
+ 45 135.00
+ 46 138.00
+ 47 141.00
+ 48 144.00
+ 49 147.00
+ 50 150.00
+EOF
+if [ $? -ne 0 ] ; then fail ; fi
+
+
+pass
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pspp-cvs] pspp doc/data-io.texi src/language/control/Chan...,
Ben Pfaff <=