Merge remote-tracking branch 'origin/master' into sheet
[pspp] / tests / language / data-io / get.at
1 dnl PSPP - a program for statistical analysis.
2 dnl Copyright (C) 2017 Free Software Foundation, Inc.
3 dnl 
4 dnl This program is free software: you can redistribute it and/or modify
5 dnl it under the terms of the GNU General Public License as published by
6 dnl the Free Software Foundation, either version 3 of the License, or
7 dnl (at your option) any later version.
8 dnl 
9 dnl This program is distributed in the hope that it will be useful,
10 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
11 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 dnl GNU General Public License for more details.
13 dnl 
14 dnl You should have received a copy of the GNU General Public License
15 dnl along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 dnl
17 AT_BANNER([GET])
18
19 dnl Tests for a bug which caused the second procedure
20 dnl after GET to have corrupt input.
21 AT_SETUP([GET data works in multiple procedures])
22 AT_DATA([get.sps], [dnl
23 DATA LIST LIST NOTABLE /LOCATION * EDITOR * SHELL * FREQ * .
24 BEGIN DATA.
25     1.00     1.00    1.0     2.00
26     1.00     1.00    2.0    30.00
27     1.00     2.00    1.0     8.00
28     1.00     2.00    2.0    20.00
29     2.00     1.00    1.0     2.00
30     2.00     1.00    2.0    22.00
31     2.00     2.00    1.0     1.00
32     2.00     2.00    2.0     3.00
33 END DATA.
34
35 SAVE /OUTFILE='foo.sav'.
36
37 GET /FILE='foo.sav'.
38
39 * This one's ok
40 LIST.
41
42 * But this one get rubbish
43 LIST.
44 ])
45 AT_CHECK([pspp -o pspp.csv get.sps])
46 AT_CHECK([cat pspp.csv], [0], [dnl
47 Table: Data List
48 LOCATION,EDITOR,SHELL,FREQ
49 1.00,1.00,1.00,2.00
50 1.00,1.00,2.00,30.00
51 1.00,2.00,1.00,8.00
52 1.00,2.00,2.00,20.00
53 2.00,1.00,1.00,2.00
54 2.00,1.00,2.00,22.00
55 2.00,2.00,1.00,1.00
56 2.00,2.00,2.00,3.00
57
58 Table: Data List
59 LOCATION,EDITOR,SHELL,FREQ
60 1.00,1.00,1.00,2.00
61 1.00,1.00,2.00,30.00
62 1.00,2.00,1.00,8.00
63 1.00,2.00,2.00,20.00
64 2.00,1.00,1.00,2.00
65 2.00,1.00,2.00,22.00
66 2.00,2.00,1.00,1.00
67 2.00,2.00,2.00,3.00
68 ])
69 AT_CLEANUP
70
71 dnl Tests for a bug that crashed when GET specified a nonexistent file.
72 AT_SETUP([GET nonexistent file doesn't crash])
73 dnl We use stdin here, because the bug seems to manifest itself only in 
74 dnl interactive mode.
75 AT_CHECK([echo "GET /FILE='nonexistent.sav'." | pspp -O format=csv], [1], [dnl
76 error: An error occurred while opening `nonexistent.sav': No such file or directory.
77 ])
78 AT_CLEANUP
79
80 dnl Tests for bug #15766 (/KEEP subcommand on SAVE doesn't
81 dnl fully support ALL) and underlying problems.
82 m4_define([GET_KEEP_ALL],
83   [AT_SETUP([GET with /KEEP=ALL crashes -- $1])
84    AT_DATA([get.sps], [dnl
85 DATA LIST LIST NOTABLE 
86         /a b c d e f g h i j k l m n o p q r s t u v w x y z (F2.0).
87 BEGIN DATA.
88 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
89 END DATA.
90 LIST.
91 SAVE OUTFILE='test.sav'/$1.
92 GET FILE='test.sav'/KEEP=x y z all.
93 LIST.
94 ])
95    AT_CHECK([pspp -o pspp.csv get.sps])
96    AT_CHECK([cat pspp.csv], [0], [dnl
97 Table: Data List
98 a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z
99 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
100
101 Table: Data List
102 x,y,z,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w
103 24,25,26,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23
104 ])
105    AT_CLEANUP])
106 GET_KEEP_ALL([uncompressed])
107 GET_KEEP_ALL([compressed])
108
109
110 dnl Test for a crash when no /TYPE was provided
111 AT_SETUP([GET data no type])
112 AT_DATA([get.sps], [dnl
113 get data /file='anything'.
114 ])
115
116 AT_CHECK([pspp get.sps], [1], [ignore])
117
118 AT_CLEANUP