Add copyright and licence notices to files which lack them.
[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 AT_BANNER([GET])
17
18 dnl Tests for a bug which caused the second procedure
19 dnl after GET to have corrupt input.
20 AT_SETUP([GET data works in multiple procedures])
21 AT_DATA([get.sps], [dnl
22 DATA LIST LIST NOTABLE /LOCATION * EDITOR * SHELL * FREQ * .
23 BEGIN DATA.
24     1.00     1.00    1.0     2.00
25     1.00     1.00    2.0    30.00
26     1.00     2.00    1.0     8.00
27     1.00     2.00    2.0    20.00
28     2.00     1.00    1.0     2.00
29     2.00     1.00    2.0    22.00
30     2.00     2.00    1.0     1.00
31     2.00     2.00    2.0     3.00
32 END DATA.
33
34 SAVE /OUTFILE='foo.sav'.
35
36 GET /FILE='foo.sav'.
37
38 * This one's ok
39 LIST.
40
41 * But this one get rubbish
42 LIST.
43 ])
44 AT_CHECK([pspp -o pspp.csv get.sps])
45 AT_CHECK([cat pspp.csv], [0], [dnl
46 Table: Data List
47 LOCATION,EDITOR,SHELL,FREQ
48 1.00,1.00,1.00,2.00
49 1.00,1.00,2.00,30.00
50 1.00,2.00,1.00,8.00
51 1.00,2.00,2.00,20.00
52 2.00,1.00,1.00,2.00
53 2.00,1.00,2.00,22.00
54 2.00,2.00,1.00,1.00
55 2.00,2.00,2.00,3.00
56
57 Table: Data List
58 LOCATION,EDITOR,SHELL,FREQ
59 1.00,1.00,1.00,2.00
60 1.00,1.00,2.00,30.00
61 1.00,2.00,1.00,8.00
62 1.00,2.00,2.00,20.00
63 2.00,1.00,1.00,2.00
64 2.00,1.00,2.00,22.00
65 2.00,2.00,1.00,1.00
66 2.00,2.00,2.00,3.00
67 ])
68 AT_CLEANUP
69
70 dnl Tests for a bug that crashed when GET specified a nonexistent file.
71 AT_SETUP([GET nonexistent file doesn't crash])
72 dnl We use stdin here, because the bug seems to manifest itself only in 
73 dnl interactive mode.
74 AT_CHECK([echo "GET /FILE='nonexistent.sav'." | pspp -O format=csv], [1], [dnl
75 error: An error occurred while opening `nonexistent.sav': No such file or directory.
76 ])
77 AT_CLEANUP
78
79 dnl Tests for bug #15766 (/KEEP subcommand on SAVE doesn't
80 dnl fully support ALL) and underlying problems.
81 m4_define([GET_KEEP_ALL],
82   [AT_SETUP([GET with /KEEP=ALL crashes -- $1])
83    AT_DATA([get.sps], [dnl
84 DATA LIST LIST NOTABLE 
85         /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).
86 BEGIN DATA.
87 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
88 END DATA.
89 LIST.
90 SAVE OUTFILE='test.sav'/$1.
91 GET FILE='test.sav'/KEEP=x y z all.
92 LIST.
93 ])
94    AT_CHECK([pspp -o pspp.csv get.sps])
95    AT_CHECK([cat pspp.csv], [0], [dnl
96 Table: Data List
97 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
98 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
99
100 Table: Data List
101 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
102 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
103 ])
104    AT_CLEANUP])
105 GET_KEEP_ALL([uncompressed])
106 GET_KEEP_ALL([compressed])
107
108
109 dnl Test for a crash when no /TYPE was provided
110 AT_SETUP([GET data no type])
111 AT_DATA([get.sps], [dnl
112 get data /file='anything'.
113 ])
114
115 AT_CHECK([pspp get.sps], [1], [ignore])
116
117 AT_CLEANUP