Convert all Perl build tools to Python and remove Perl build dependency.
[pspp] / tests / language / data-io / get-data-txt.at
index 60409df37e74abd59e74f905fb7ed3b9af76b578..950c2ad7a96cfc66ae231c434dbc60ab18c1fce8 100644 (file)
@@ -1,3 +1,19 @@
+dnl PSPP - a program for statistical analysis.
+dnl Copyright (C) 2017 Free Software Foundation, Inc.
+dnl
+dnl This program is free software: you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation, either version 3 of the License, or
+dnl (at your option) any later version.
+dnl
+dnl This program is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+dnl GNU General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program.  If not, see <http://www.gnu.org/licenses/>.
+dnl
 AT_BANNER([GET DATA /TYPE=TXT])
 
 dnl These tests exercise features of GET DATA /TYPE=TXT that
@@ -145,7 +161,7 @@ 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 
+       /1 x 0 f
            y 1 f.
 begin data.
 12
@@ -197,10 +213,10 @@ 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@
+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_CLEANUP
 
@@ -237,17 +253,17 @@ 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
+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
+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
 
@@ -263,7 +279,7 @@ AT_DATA([pets.data], [dnl
 "Gilly", , White, "10 Apr 2007", 10, "3""", "Guinea Pig"
 ])
 AT_DATA([pets.sps], [dnl
-GET DATA /TYPE=TXT /FILE='pets.data' /DELIMITERS=', ' /QUALIFIER='''"' /ESCAPE
+GET DATA /TYPE=TXT /FILE='pets.data' /DELIMITERS=', ' /QUALIFIER='''"'
         /FIRSTCASE=3
         /VARIABLES=name A10
                    age F3.1
@@ -278,297 +294,36 @@ 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
+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
 ])
 AT_CLEANUP
 dnl " (fixes Emacs highlighting)
 
 AT_SETUP([GET DATA /TYPE=TXT with IMPORTCASE])
-AT_CHECK([$PERL > test.data <<'EOF'
-for ($i = 1; $i <= 100; $i++) {
-    printf "%02d\n", $i;
-}
-EOF
-])
+AT_CHECK([$PYTHON3 > test.data -c '
+for i in range(1, 101):
+    print("%02d" % i)
+'])
 AT_DATA([get-data.sps], [dnl
 get data /type=txt /file='test.data' /importcase=first 10 /variables x f8.0.
-list.
-
 get data /type=txt /file='test.data' /importcase=percent 1 /variables x f8.0.
-list.
-
 get data /type=txt /file='test.data' /importcase=percent 35 /variables x f8.0.
-list.
-
 get data /type=txt /file='test.data' /importcase=percent 95 /variables x f8.0.
-list.
-
 get data /type=txt /file='test.data' /importcase=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
+AT_CHECK([pspp -O format=csv get-data.sps], [0], [dnl
+get-data.sps:1: warning: GET DATA: Ignoring obsolete IMPORTCASES subcommand.  (N OF CASES or SAMPLE may be used to substitute.)
 
-Table: Data List
-x
-1
-2
+get-data.sps:2: warning: GET DATA: Ignoring obsolete IMPORTCASES subcommand.  (N OF CASES or SAMPLE may be used to substitute.)
 
-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
+get-data.sps:3: warning: GET DATA: Ignoring obsolete IMPORTCASES subcommand.  (N OF CASES or SAMPLE may be used to substitute.)
 
-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
+get-data.sps:4: warning: GET DATA: Ignoring obsolete IMPORTCASES subcommand.  (N OF CASES or SAMPLE may be used to substitute.)
 
-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
+get-data.sps:5: warning: GET DATA: Ignoring obsolete IMPORTCASES subcommand.  (N OF CASES or SAMPLE may be used to substitute.)
 ])
 AT_CLEANUP
 
@@ -585,6 +340,78 @@ AT_CHECK([pspp -o pspp.csv get-data.sps])
 AT_CHECK([cat pspp.csv], [0], [dnl
 Table: Data List
 s
-é      @&t@
+])
+AT_CLEANUP
+
+
+AT_SETUP([GET DATA /TYPE= truncated])
+
+AT_DATA([x.sps], [dnl
+GET DATA /TYPE=
+.
+])
+
+AT_CHECK([pspp -o pspp.csv x.sps], [1], [ignore])
+
+AT_CLEANUP
+
+
+
+AT_SETUP([GET DATA /TYPE=txt bug])
+
+
+AT_DATA([thing.txt], [dnl
+foo, title, last
+1, this, 1
+2, that, 2
+3, other, 3
+])
+
+AT_DATA([x.sps], [dnl
+GET DATA
+  /TYPE=TXT
+  /FILE="thing.txt"
+  /ARRANGEMENT=DELIMITED
+  /DELCASE=LINE
+  /FIRSTCASE=2
+  /DELIMITERS=","
+  /VARIABLES=foo F1.0
+    title A8
+    last F2.0.
+
+list.
+])
+
+AT_CHECK([pspp -O format=csv x.sps], [0], [dnl
+Table: Data List
+foo,title,last
+1,this,1
+2,that,2
+3,other,3
+])
+
+AT_CLEANUP
+
+
+
+AT_SETUP([GET DATA /TYPE=txt another bug])
+
+AT_DATA([crash.sps], [dnl
+get data /type=txt /file=inline /variables=C f7.2 D f7>2.
+begin data.
+3 2
+4 2
+5 2
+end data.
 ])
+
+AT_CHECK([pspp -O format=csv crash.sps], [1], [ignore])
+
 AT_CLEANUP
+
+
+
+
+
+