pspp-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[csv 06/10] DATA LIST: Convert tests to use Autotest.


From: Ben Pfaff
Subject: [csv 06/10] DATA LIST: Convert tests to use Autotest.
Date: Sun, 8 Aug 2010 10:17:48 -0700

---
 tests/automake.mk                   |    2 +-
 tests/command/data-list.sh          |  212 -----------------------------------
 tests/language/data-io/data-list.at |  163 +++++++++++++++++++++++++++
 3 files changed, 164 insertions(+), 213 deletions(-)
 delete mode 100755 tests/command/data-list.sh
 create mode 100644 tests/language/data-io/data-list.at

diff --git a/tests/automake.mk b/tests/automake.mk
index abf61d1..1d24735 100644
--- a/tests/automake.mk
+++ b/tests/automake.mk
@@ -16,7 +16,6 @@ dist_TESTS = \
        tests/command/bignum.sh \
        tests/command/count.sh \
        tests/command/correlation.sh \
-       tests/command/data-list.sh \
        tests/command/do-if.sh \
        tests/command/do-repeat.sh \
        tests/command/erase.sh \
@@ -419,6 +418,7 @@ EXTRA_DIST += \
 
 TESTSUITE_AT = \
        tests/data/calendar.at \
+       tests/language/data-io/data-list.at \
        tests/language/dictionary/mrsets.at \
        tests/language/expressions/evaluate.at \
        tests/language/stats/aggregate.at \
diff --git a/tests/command/data-list.sh b/tests/command/data-list.sh
deleted file mode 100755
index 86a70ee..0000000
--- a/tests/command/data-list.sh
+++ /dev/null
@@ -1,212 +0,0 @@
-#!/bin/sh
-
-# This program tests the DATA LIST input program.
-
-TEMPDIR=/tmp/pspp-tst-$$
-TESTFILE=$TEMPDIR/`basename $0`.sps
-
-# 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$EXEEXT
-
-# ensure that top_srcdir is absolute
-top_srcdir=`cd $top_srcdir; pwd`
-
-STAT_CONFIG_PATH=$top_srcdir/config
-export STAT_CONFIG_PATH
-
-
-cleanup()
-{
-     if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then 
-       echo "NOT cleaning $TEMPDIR" 
-       return ; 
-     fi
-     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
-
-# Create command file.
-activity="create program"
-cat > $TESTFILE << EOF
-data list list ('|','X') /A B C D.
-begin data.
-1|23X45|2.03
-2X22|34|23|
-3|34|34X34
-end data.
-
-list.
-
-data list free skip=1/A B C D.
-begin data.
-# This record is ignored.
-,1,2,3
-,4,,5
-6
-7,
-8 9
-0,1 ,,,
-,,,,
-2
-
-3
-4
-5
-end data.
-list.
-
-data list free (tab) skip=2/A B C D.
-begin data.
-# These records
-# are skipped.
-1      2       3       4
-1      2       3       
-1      2               4
-1      2               
-1              3       4
-1              3       
-1                      4
-1                      
-       2       3       4
-       2       3       
-       2               4
-       2               
-               3       4
-               3       
-                       4
-                       
-end data.
-list.
-
-* Test DATA LIST FIXED with multiple records.
-data list fixed notable
-       /1 start 1-20 (adate)
-       /2 end 1-20 (adate)
-       /3 count 1-3.
-begin data.
-07-22-2007
-10-06-2007
-321
-07-14-1789
-08-26-1789
-4
-01-01-1972
-12-31-1999
-682
-end data.
-list.
-
-* Test that DATA LIST FIXED works with an empty trailing record.
-data list fixed notable records=2/x 1 y 2.
-begin data.
-12
-
-34
-
-56
-
-78
-
-90
-
-end data.
-list.
-EOF
-if [ $? -ne 0 ] ; then no_result ; fi
-
-
-activity="run program"
-$SUPERVISOR $PSPP -o pspp.csv $TESTFILE
-if [ $? -ne 0 ] ; then fail ; fi
-
-activity="compare output"
-diff -c $TEMPDIR/pspp.csv - << EOF
-Table: Reading free-form data from INLINE.
-Variable,Format
-A,F8.0
-B,F8.0
-C,F8.0
-D,F8.0
-
-Table: Data List
-A,B,C,D
-1.00,23.00,45.00,2.03
-2.00,22.00,34.00,23.00
-3.00,34.00,34.00,34.00
-
-Table: Data List
-A,B,C,D
-.  ,1.00,2.00,3.00
-.  ,4.00,.  ,5.00
-6.00,7.00,8.00,9.00
-.00,1.00,.  ,.  
-.  ,.  ,.  ,.  
-2.00,3.00,4.00,5.00
-
-Table: Data List
-A,B,C,D
-1.00,2.00,3.00,4.00
-1.00,2.00,3.00,.  
-1.00,2.00,.  ,4.00
-1.00,2.00,.  ,.  
-1.00,.  ,3.00,4.00
-1.00,.  ,3.00,.  
-1.00,.  ,.  ,4.00
-1.00,.  ,.  ,.  
-.  ,2.00,3.00,4.00
-.  ,2.00,3.00,.  
-.  ,2.00,.  ,4.00
-.  ,2.00,.  ,.  
-.  ,.  ,3.00,4.00
-.  ,.  ,3.00,.  
-.  ,.  ,.  ,4.00
-.  ,.  ,.  ,.  
-
-Table: Data List
-start,end,count
-07/22/2007,10/06/2007,321
-07/14/1789,08/26/1789,4
-01/01/1972,12/31/1999,682
-
-Table: Data List
-x,y
-1,2
-3,4
-5,6
-7,8
-9,0
-EOF
-if [ $? -ne 0 ] ; then fail ; fi
-
-pass;
diff --git a/tests/language/data-io/data-list.at 
b/tests/language/data-io/data-list.at
new file mode 100644
index 0000000..746ea77
--- /dev/null
+++ b/tests/language/data-io/data-list.at
@@ -0,0 +1,163 @@
+AT_BANNER([DATA LIST])
+
+AT_SETUP([DATA LIST LIST with explicit delimiters])
+AT_DATA([data-list.pspp], [dnl
+data list list ('|','X') /A B C D.
+begin data.
+1|23X45|2.03
+2X22|34|23|
+3|34|34X34
+end data.
+
+list.
+])
+AT_CHECK([pspp -O format=csv data-list.pspp], [0], [dnl
+Table: Reading free-form data from INLINE.
+Variable,Format
+A,F8.0
+B,F8.0
+C,F8.0
+D,F8.0
+
+Table: Data List
+A,B,C,D
+1.00,23.00,45.00,2.03
+2.00,22.00,34.00,23.00
+3.00,34.00,34.00,34.00
+])
+AT_CLEANUP
+
+AT_SETUP([DATA LIST FREE with SKIP])
+AT_DATA([data-list.pspp], [dnl
+data list free skip=1/A B C D.
+begin data.
+# This record is ignored.
+,1,2,3
+,4,,5
+6
+7,
+8 9
+0,1 ,,,
+,,,,
+2
+
+3
+4
+5
+end data.
+list.
+])
+AT_CHECK([pspp -O format=csv data-list.pspp], [0], [dnl
+Table: Data List
+A,B,C,D
+.  ,1.00,2.00,3.00
+.  ,4.00,.  ,5.00
+6.00,7.00,8.00,9.00
+.00,1.00,.  ,.  @&t@
+.  ,.  ,.  ,.  @&t@
+2.00,3.00,4.00,5.00
+])
+AT_CLEANUP
+
+AT_SETUP([DATA LIST LIST with SKIP and tab delimiter])
+AT_DATA([data-list.pspp], [dnl
+data list free (tab) skip=2/A B C D.
+begin data.
+# These records
+# are skipped.
+1      2       3       4
+1      2       3       @&t@
+1      2               4
+1      2               @&t@
+1              3       4
+1              3       @&t@
+1                      4
+1                      @&t@
+       2       3       4
+       2       3       @&t@
+       2               4
+       2               @&t@
+               3       4
+               3       @&t@
+                       4
+                       @&t@
+end data.
+list.
+])
+AT_CHECK([pspp -O format=csv data-list.pspp], [0], [dnl
+Table: Data List
+A,B,C,D
+1.00,2.00,3.00,4.00
+1.00,2.00,3.00,.  @&t@
+1.00,2.00,.  ,4.00
+1.00,2.00,.  ,.  @&t@
+1.00,.  ,3.00,4.00
+1.00,.  ,3.00,.  @&t@
+1.00,.  ,.  ,4.00
+1.00,.  ,.  ,.  @&t@
+.  ,2.00,3.00,4.00
+.  ,2.00,3.00,.  @&t@
+.  ,2.00,.  ,4.00
+.  ,2.00,.  ,.  @&t@
+.  ,.  ,3.00,4.00
+.  ,.  ,3.00,.  @&t@
+.  ,.  ,.  ,4.00
+.  ,.  ,.  ,.  @&t@
+])
+AT_CLEANUP
+
+AT_SETUP([DATA LIST FIXED with multiple records per case])
+AT_DATA([data-list.pspp], [dnl
+data list fixed notable
+        /1 start 1-20 (adate)
+        /2 end 1-20 (adate)
+        /3 count 1-3.
+begin data.
+07-22-2007
+10-06-2007
+321
+07-14-1789
+08-26-1789
+4
+01-01-1972
+12-31-1999
+682
+end data.
+list.
+])
+AT_CHECK([pspp -O format=csv data-list.pspp], [0], [dnl
+Table: Data List
+start,end,count
+07/22/2007,10/06/2007,321
+07/14/1789,08/26/1789,4
+01/01/1972,12/31/1999,682
+])
+AT_CLEANUP
+
+AT_SETUP([DATA LIST FIXED with empty trailing record])
+AT_DATA([data-list.pspp], [dnl
+data list fixed notable records=2/x 1 y 2.
+begin data.
+12
+
+34
+
+56
+
+78
+
+90
+
+end data.
+list.
+])
+AT_CHECK([pspp -O format=csv data-list.pspp], [0], [dnl
+Table: Data List
+x,y
+1,2
+3,4
+5,6
+7,8
+9,0
+])
+AT_CLEANUP
-- 
1.7.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]