From: Ben Pfaff Date: Sun, 26 Sep 2010 03:55:24 +0000 (-0700) Subject: tests: Convert GET DATA /TYPE=TXT tests to use Autotest. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?p=pspp;a=commitdiff_plain;h=872878020f28b1a858a80de5f7baa1ada1d9a0c2 tests: Convert GET DATA /TYPE=TXT tests to use Autotest. --- diff --git a/doc/files.texi b/doc/files.texi index 707447e099..5f0c527c47 100644 --- a/doc/files.texi +++ b/doc/files.texi @@ -485,7 +485,7 @@ The following syntax reads a file in the format used by @samp{/etc/passwd}: @c If you change this example, change the regression test in -@c tests/command/get-data-txt-examples.sh to match. +@c tests/language/data-io/get-data.at to match. @example GET DATA /TYPE=TXT /FILE='/etc/passwd' /DELIMITERS=':' /VARIABLES=username A20 @@ -512,7 +512,7 @@ Accord 2002 26613 17900 EX 1 The following syntax can be used to read the used car data: @c If you change this example, change the regression test in -@c tests/command/get-data-txt-examples.sh to match. +@c tests/language/data-io/get-data.at to match. @example GET DATA /TYPE=TXT /FILE='cars.data' /DELIMITERS=' ' /FIRSTCASE=2 /VARIABLES=model A8 @@ -539,7 +539,7 @@ Consider the following information on animals in a pet store: The following syntax can be used to read the pet store data: @c If you change this example, change the regression test in -@c tests/command/get-data-txt-examples.sh to match. +@c tests/language/data-io/get-data.at to match. @example GET DATA /TYPE=TXT /FILE='pets.data' /DELIMITERS=', ' /QUALIFIER='''"' /ESCAPE /FIRSTCASE=3 @@ -608,7 +608,7 @@ Accord 2002 26613 17900 EX 1 The following syntax can be used to read the used car data: @c If you change this example, change the regression test in -@c tests/command/get-data-txt-examples.sh to match. +@c tests/language/data-io/get-data.at to match. @example GET DATA /TYPE=TXT /FILE='cars.data' /ARRANGEMENT=FIXED /FIRSTCASE=2 /VARIABLES=model 0-7 A diff --git a/tests/automake.mk b/tests/automake.mk index 297c21758f..b4f29dd450 100644 --- a/tests/automake.mk +++ b/tests/automake.mk @@ -10,9 +10,6 @@ TESTS_ENVIRONMENT += LC_ALL=C TESTS_ENVIRONMENT += EXEEXT=$(EXEEXT) dist_TESTS = \ - tests/command/get-data-txt.sh \ - tests/command/get-data-txt-examples.sh \ - tests/command/get-data-txt-importcases.sh \ tests/command/import-export.sh \ tests/command/insert.sh \ tests/command/lag.sh \ @@ -386,6 +383,7 @@ TESTSUITE_AT = \ tests/language/data-io/data-list.at \ tests/language/data-io/data-reader.at \ tests/language/data-io/file-handle.at \ + tests/language/data-io/get-data.at \ tests/language/data-io/save.at \ tests/language/data-io/save-translate.at \ tests/language/dictionary/attributes.at \ diff --git a/tests/command/get-data-txt-examples.sh b/tests/command/get-data-txt-examples.sh deleted file mode 100755 index 3900fa403c..0000000000 --- a/tests/command/get-data-txt-examples.sh +++ /dev/null @@ -1,172 +0,0 @@ -#!/bin/sh - -# This program tests the examples for GET DATA/TYPE=TXT given in the -# PSPP 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$EXEEXT - -# 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() -{ - 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 - -activity="create passwd.data" -cat > passwd.data <<'EOF' -root:$1$nyeSP5gD$pDq/:0:0:,,,:/root:/bin/bash -blp:$1$BrP/pFg4$g7OG:1000:1000:Ben Pfaff,,,:/home/blp:/bin/bash -john:$1$JBuq/Fioq$g4A:1001:1001:John Darrington,,,:/home/john:/bin/bash -jhs:$1$D3li4hPL$88X1:1002:1002:Jason Stover,,,:/home/jhs:/bin/csh -EOF -if [ $? -ne 0 ] ; then no_result ; fi - -activity="create cars.data" -cat > cars.data <<'EOF' -model year mileage price type age -Civic 2002 29883 15900 Si 2 -Civic 2003 13415 15900 EX 1 -Civic 1992 107000 3800 n/a 12 -Accord 2002 26613 17900 EX 1 -EOF -if [ $? -ne 0 ] ; then no_result ; fi - -activity="create pets.data" -cat > pets.data <<'EOF' -'Pet''s Name', "Age", "Color", "Date Received", "Price", "Height", "Type" -, (Years), , , (Dollars), , -"Rover", 4.5, Brown, "12 Feb 2004", 80, '1''4"', "Dog" -"Charlie", , Gold, "5 Apr 2007", 12.3, "3""", "Fish" -"Molly", 2, Black, "12 Dec 2006", 25, '5"', "Cat" -"Gilly", , White, "10 Apr 2007", 10, "3""", "Guinea Pig" -EOF -if [ $? -ne 0 ] ; then no_result ; fi - -activity="create test.pspp" -cat > test.pspp <<'EOF' -GET DATA /TYPE=TXT /FILE='passwd.data' /DELIMITERS=':' - /VARIABLES=username A20 - password A40 - uid F10 - gid F10 - gecos A40 - home A40 - shell A40. -LIST. - -GET DATA /TYPE=TXT /FILE='cars.data' /DELIMITERS=' ' /FIRSTCASE=2 - /VARIABLES=model A8 - year F4 - mileage F6 - price F5 - type A4 - age F2. -LIST. - -GET DATA /TYPE=TXT /FILE='cars.data' /ARRANGEMENT=FIXED /FIRSTCASE=2 - /VARIABLES=model 0-7 A - year 8-15 F - mileage 16-23 F - price 24-31 F - type 32-39 A - age 40-47 F. -LIST. - -GET DATA /TYPE=TXT /FILE='pets.data' /DELIMITERS=', ' /QUALIFIER='''"' /ESCAPE - /FIRSTCASE=3 - /VARIABLES=name A10 - age F3.1 - color A5 - received EDATE10 - price F5.2 - height a5 - type a10. -LIST. -EOF -if [ $? -ne 0 ] ; then no_result ; fi - -activity="run test" -$SUPERVISOR $PSPP -o pspp.csv test.pspp -if [ $? -ne 0 ] ; then no_result ; fi - -activity="compare test results" -diff -c $TEMPDIR/pspp.csv - <<'EOF' -Table: Data List -username,password,uid,gid,gecos,home,shell -root ,$1$nyeSP5gD$pDq/ ,0,0,",,, ",/root ,/bin/bash -blp ,$1$BrP/pFg4$g7OG ,1000,1000,"Ben Pfaff,,, ",/home/blp ,/bin/bash -john ,$1$JBuq/Fioq$g4A ,1001,1001,"John Darrington,,, ",/home/john ,/bin/bash -jhs ,$1$D3li4hPL$88X1 ,1002,1002,"Jason Stover,,, ",/home/jhs ,/bin/csh - -Table: Data List -model,year,mileage,price,type,age -Civic ,2002,29883,15900,Si ,2 -Civic ,2003,13415,15900,EX ,1 -Civic ,1992,107000,3800,n/a ,12 -Accord ,2002,26613,17900,EX ,1 - -Table: Data List -model,year,mileage,price,type,age -Civic ,2002,29883,15900,Si ,2 -Civic ,2003,13415,15900,EX ,1 -Civic ,1992,107000,3800,n/a ,12 -Accord ,2002,26613,17900,EX ,1 - -Table: Data List -name,age,color,received,price,height,type -Rover ,4.5,Brown,12.02.2004,80.00,"1'4"" ",Dog -Charlie ,. ,Gold ,05.04.2007,12.30,"3"" ",Fish -Molly ,2.0,Black,12.12.2006,25.00,"5"" ",Cat -Gilly ,. ,White,10.04.2007,10.00,"3"" ",Guinea Pig -EOF -if [ $? -ne 0 ] ; then fail ; fi - - - -pass diff --git a/tests/command/get-data-txt-importcases.sh b/tests/command/get-data-txt-importcases.sh deleted file mode 100755 index 82742ead09..0000000000 --- a/tests/command/get-data-txt-importcases.sh +++ /dev/null @@ -1,355 +0,0 @@ -#!/bin/sh - -# This program tests the IMPORTCASES feature of GET DATA /TYPE=TXT. - -TEMPDIR=/tmp/pspp-tst-$$ -TESTFILE=$TEMPDIR/`basename $0`.sps -: ${PERL:=perl} - -# 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 - -activity="create data file using Perl" -$PERL > test.data <<'EOF' -for ($i = 1; $i <= 100; $i++) { - printf "%02d\n", $i; -} -EOF -if [ $? -ne 0 ] ; then no_result ; fi - -# Create command file. -activity="create program" -cat > $TESTFILE << EOF -get data /type=txt /file='test.data' /importcases=first 10 /variables x f8.0. -list. - -get data /type=txt /file='test.data' /importcases=percent 1 /variables x f8.0. -list. - -get data /type=txt /file='test.data' /importcases=percent 35 /variables x f8.0. -list. - -get data /type=txt /file='test.data' /importcases=percent 95 /variables x f8.0. -list. - -get data /type=txt /file='test.data' /importcases=percent 100 /variables x f8.0. -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: Data List -x -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 - -Table: Data List -x -1 -2 - -Table: Data List -x -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 - -Table: Data List -x -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 - -Table: Data List -x -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -EOF -if [ $? -ne 0 ] ; then fail ; fi - -pass; diff --git a/tests/command/get-data-txt.sh b/tests/command/get-data-txt.sh deleted file mode 100755 index bc56081357..0000000000 --- a/tests/command/get-data-txt.sh +++ /dev/null @@ -1,211 +0,0 @@ -#!/bin/sh - -# This program tests features of GET DATA /TYPE=TXT input program that -# it has in common with DATA LIST, using tests drawn from -# data-list.sh. - -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 -get data /type=txt /file=inline /delimiters="|X" - /variables=A f7.2 B f7.2 C f7.2 D f7.2. -begin data. -1|23X45|2.03 -2X22|34|23| -3|34|34X34 -end data. - -list. - -get data /type=txt /file=inline /delimiters=', ' /delcase=variables 4 - /firstcase=2 /variables=A f7.2 B f7.2 C f7.2 D f7.2. -begin data. -# This record is ignored. -,1,2,3 -,4,,5 -6 -7, -8 9 -0,1,,, -,,,, -2 - -3 -4 -5 -end data. -list. - -get data /type=txt /file=inline /delimiters='\t' /delcase=variables 4 - /firstcase=3 /variables=A f7.2 B f7.2 C f7.2 D f7.2. -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. - -get data /type=txt /file=inline /arrangement=fixed /fixcase=3 /variables= - /1 start 0-19 adate - /2 end 0-19 adate - /3 count 0-2 f. -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. - -get data /type=txt /file=inline /arrangement=fixed /fixcase=2 /variables= - /1 x 0 f - y 1 f. -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 -b $TEMPDIR/pspp.csv - << EOF -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/get-data.at b/tests/language/data-io/get-data.at new file mode 100644 index 0000000000..1ce180a9cc --- /dev/null +++ b/tests/language/data-io/get-data.at @@ -0,0 +1,569 @@ +at_BANNER([GET DATA /TYPE=TXT]) + +dnl These tests exercise features of GET DATA /TYPE=TXT that +dnl it has in common with DATA LIST, using tests drawn from +dnl DATA LIST. + +AT_SETUP([GET DATA /TYPE=TXT with explicit delimiters]) +AT_DATA([get-data.sps], [dnl +get data /type=txt /file=inline /delimiters="|X" + /variables=A f7.2 B f7.2 C f7.2 D f7.2. +begin data. +1|23X45|2.03 +2X22|34|23| +3|34|34X34 +end data. + +list. +]) +AT_CHECK([pspp -o pspp.csv get-data.sps]) +AT_CHECK([cat pspp.csv], [0], [dnl +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([GET DATA /TYPE=TXT with FIRSTCASE]) +AT_DATA([get-data.sps], [dnl +get data /type=txt /file=inline /delimiters=', ' /delcase=variables 4 + /firstcase=2 /variables=A f7.2 B f7.2 C f7.2 D f7.2. +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 pspp.csv get-data.sps]) +AT_CHECK([cat pspp.csv], [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([GET DATA /TYPE=TXT with FIRSTCASE and tab delimiter]) +AT_DATA([get-data.sps], [dnl +get data /type=txt /file=inline /delimiters='\t' /delcase=variables 4 + /firstcase=3 /variables=A f7.2 B f7.2 C f7.2 D f7.2. +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 pspp.csv get-data.sps]) +AT_CHECK([cat pspp.csv], [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([GET DATA /TYPE=TXT with multiple records per case]) +AT_DATA([get-data.sps], [dnl +get data /type=txt /file=inline /arrangement=fixed /fixcase=3 /variables= + /1 start 0-19 adate + /2 end 0-19 adate + /3 count 0-2 f. +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 pspp.csv get-data.sps]) +AT_CHECK([cat pspp.csv], [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([GET DATA /TYPE=TXT with empty trailing record]) +AT_DATA([get-data.sps], [dnl +get data /type=txt /file=inline /arrangement=fixed /fixcase=2 /variables= + /1 x 0 f + y 1 f. +begin data. +12 + +34 + +56 + +78 + +90 + +end data. +list. +]) +AT_CHECK([pspp -o pspp.csv get-data.sps]) +AT_CHECK([cat pspp.csv], [0], [dnl +Table: Data List +x,y +1,2 +3,4 +5,6 +7,8 +9,0 +]) +AT_CLEANUP + +dnl This test is a copy of an example given in the manual +dnl in doc/files.texi. +AT_SETUP([GET DATA /TYPE=TXT password example]) +AT_DATA([passwd.data], [dnl +root:$1$nyeSP5gD$pDq/:0:0:,,,:/root:/bin/bash +blp:$1$BrP/pFg4$g7OG:1000:1000:Ben Pfaff,,,:/home/blp:/bin/bash +john:$1$JBuq/Fioq$g4A:1001:1001:John Darrington,,,:/home/john:/bin/bash +jhs:$1$D3li4hPL$88X1:1002:1002:Jason Stover,,,:/home/jhs:/bin/csh +]) +AT_DATA([passwd.sps], [dnl +GET DATA /TYPE=TXT /FILE='passwd.data' /DELIMITERS=':' + /VARIABLES=username A20 + password A40 + uid F10 + gid F10 + gecos A40 + home A40 + shell A40. +LIST. +]) +AT_CHECK([pspp -o pspp.csv passwd.sps]) +AT_CHECK([cat pspp.csv], [0], [dnl +Table: Data List +username,password,uid,gid,gecos,home,shell +root ,$1$nyeSP5gD$pDq/ ,0,0,",,, ",/root ,/bin/bash @&t@ +blp ,$1$BrP/pFg4$g7OG ,1000,1000,"Ben Pfaff,,, ",/home/blp ,/bin/bash @&t@ +john ,$1$JBuq/Fioq$g4A ,1001,1001,"John Darrington,,, ",/home/john ,/bin/bash @&t@ +jhs ,$1$D3li4hPL$88X1 ,1002,1002,"Jason Stover,,, ",/home/jhs ,/bin/csh @&t@ +]) +AT_CLEANUP + +dnl This test is a copy of an example given in the manual +dnl in doc/files.texi. +AT_SETUP([GET DATA /TYPE=TXT cars example]) +AT_DATA([cars.data], [dnl +model year mileage price type age +Civic 2002 29883 15900 Si 2 +Civic 2003 13415 15900 EX 1 +Civic 1992 107000 3800 n/a 12 +Accord 2002 26613 17900 EX 1 +]) +AT_DATA([cars.sps], [dnl +GET DATA /TYPE=TXT /FILE='cars.data' /DELIMITERS=' ' /FIRSTCASE=2 + /VARIABLES=model A8 + year F4 + mileage F6 + price F5 + type A4 + age F2. +LIST. + +GET DATA /TYPE=TXT /FILE='cars.data' /ARRANGEMENT=FIXED /FIRSTCASE=2 + /VARIABLES=model 0-7 A + year 8-15 F + mileage 16-23 F + price 24-31 F + type 32-39 A + age 40-47 F. +LIST. +]) +AT_CHECK([pspp -o pspp.csv cars.sps]) +AT_CHECK([cat pspp.csv], [0], [dnl +Table: Data List +model,year,mileage,price,type,age +Civic ,2002,29883,15900,Si ,2 +Civic ,2003,13415,15900,EX ,1 +Civic ,1992,107000,3800,n/a ,12 +Accord ,2002,26613,17900,EX ,1 + +Table: Data List +model,year,mileage,price,type,age +Civic ,2002,29883,15900,Si ,2 +Civic ,2003,13415,15900,EX ,1 +Civic ,1992,107000,3800,n/a ,12 +Accord ,2002,26613,17900,EX ,1 +]) +AT_CLEANUP + +dnl This test is a copy of an example given in the manual +dnl in doc/files.texi. +AT_SETUP([GET DATA /TYPE=TXT pets example]) +AT_DATA([pets.data], [dnl +'Pet''s Name', "Age", "Color", "Date Received", "Price", "Height", "Type" +, (Years), , , (Dollars), , +"Rover", 4.5, Brown, "12 Feb 2004", 80, '1''4"', "Dog" +"Charlie", , Gold, "5 Apr 2007", 12.3, "3""", "Fish" +"Molly", 2, Black, "12 Dec 2006", 25, '5"', "Cat" +"Gilly", , White, "10 Apr 2007", 10, "3""", "Guinea Pig" +]) +AT_DATA([pets.sps], [dnl +GET DATA /TYPE=TXT /FILE='pets.data' /DELIMITERS=', ' /QUALIFIER='''"' /ESCAPE + /FIRSTCASE=3 + /VARIABLES=name A10 + age F3.1 + color A5 + received EDATE10 + price F5.2 + height a5 + type a10. +LIST. +]) +AT_CHECK([pspp -o pspp.csv pets.sps]) +AT_CHECK([cat pspp.csv], [0], [dnl +Table: Data List +name,age,color,received,price,height,type +Rover ,4.5,Brown,12.02.2004,80.00,"1'4"" ",Dog @&t@ +Charlie ,. ,Gold ,05.04.2007,12.30,"3"" ",Fish @&t@ +Molly ,2.0,Black,12.12.2006,25.00,"5"" ",Cat @&t@ +Gilly ,. ,White,10.04.2007,10.00,"3"" ",Guinea Pig +]) +AT_CLEANUP + +AT_SETUP([GET DATA /TYPE=TXT with IMPORTCASES]) +AT_CHECK([$PERL > test.data <<'EOF' +for ($i = 1; $i <= 100; $i++) { + printf "%02d\n", $i; +} +EOF +]) +AT_DATA([get-data.sps], [dnl +get data /type=txt /file='test.data' /importcases=first 10 /variables x f8.0. +list. + +get data /type=txt /file='test.data' /importcases=percent 1 /variables x f8.0. +list. + +get data /type=txt /file='test.data' /importcases=percent 35 /variables x f8.0. +list. + +get data /type=txt /file='test.data' /importcases=percent 95 /variables x f8.0. +list. + +get data /type=txt /file='test.data' /importcases=percent 100 /variables x f8.0. +list. +]) +AT_CHECK([pspp -o pspp.csv get-data.sps]) +AT_CHECK([cat pspp.csv], [0], [dnl +Table: Data List +x +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 + +Table: Data List +x +1 +2 + +Table: Data List +x +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 + +Table: Data List +x +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 + +Table: Data List +x +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +]) +AT_CLEANUP