Automatically infer variables' measurement level from format and data.
[pspp] / tests / language / dictionary / sys-file-info.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([SYSFILE INFO])
18
19 AT_SETUP([SYSFILE INFO])
20 AT_DATA([sysfile-info.sps], [dnl
21 DATA LIST LIST /x * name (a10) .
22 BEGIN DATA
23 1 one
24 2 two
25 3 three
26 END DATA.
27 DOCUMENT A document.
28 SAVE OUTFILE='pro.sav'.
29
30 sysfile info file='pro.sav'.
31 ])
32 AT_CHECK([pspp -o pspp.csv sysfile-info.sps])
33 AT_CHECK(
34   [sed -e '/^Created,/d' \
35        -e '/^Endian,/d' \
36        -e '/^Integer Format,/d' \
37        -e '/^Real Format,/d' \
38        -e '/^Encoding,/d' \
39        -e 's/(Entered.*)/(Entered <date>)/' pspp.csv],
40   [0], [dnl
41 Table: Reading free-form data from INLINE.
42 Variable,Format
43 x,F8.0
44 name,A10
45
46 Table: File Information
47 File,pro.sav
48 Variables,2
49 Cases,3
50 Type,SPSS System File
51 Weight,Not weighted
52 Compression,SAV
53 Documents,"DOCUMENT A document.
54    (Entered <date>)"
55
56 Table: Variables
57 Name,Position,Measurement Level,Role,Width,Alignment,Print Format,Write Format
58 x,1,Nominal,Input,8,Right,F8.2,F8.2
59 name,2,Nominal,Input,10,Left,A10,A10
60 ])
61 AT_CLEANUP
62
63 AT_BANNER([DISPLAY])
64
65 dnl DISPLAY DOCUMENTS is tested with commands for documents.
66
67 AT_SETUP([DISPLAY FILE LABEL])
68 AT_DATA([display.sps], [dnl
69 DATA LIST LIST NOTABLE /x * name (a10) .
70
71 DISPLAY FILE LABEL.
72
73 FILE LABEL 'foo bar baz quux'.
74 DISPLAY FILE LABEL.
75 ])
76 AT_CHECK([pspp -O format=csv display.sps], [0], [dnl
77 Table: File Label
78 Label,(none)
79
80 Table: File Label
81 Label,foo bar baz quux
82 ])
83 AT_CLEANUP
84
85 dnl DISPLAY VECTORS is tested with commands for vectors.
86
87 dnl DISPLAY ATTRIBUTES and @ATTRIBUTES are tested with commands for attributes.
88
89 AT_SETUP([DISPLAY SCRATCH])
90 AT_DATA([sysfile-info.sps], [dnl
91 DATA LIST LIST NOTABLE /x * name (a10) .
92 DISPLAY SCRATCH.
93 COMPUTE #x=0.
94 DISPLAY SCRATCH.
95 ])
96 AT_CHECK([pspp -O format=csv sysfile-info.sps], [0], [dnl
97 sysfile-info.sps:2: warning: DISPLAY: No variables to display.
98
99 Table: Variables
100 Name
101 #x
102 ])
103 AT_CLEANUP
104
105 AT_SETUP([DISPLAY INDEX])
106 AT_DATA([sysfile-info.sps], [dnl
107 DATA LIST LIST NOTABLE /x * name (a10) .
108 DISPLAY INDEX.
109 ])
110 AT_CHECK([pspp -O format=csv sysfile-info.sps], [0], [dnl
111 Table: Variables
112 Name,Position
113 x,1
114 name,2
115 ])
116 AT_CLEANUP
117
118 AT_SETUP([DISPLAY NAMES])
119 AT_DATA([sysfile-info.sps], [dnl
120 DATA LIST LIST NOTABLE /x * name (a10) .
121 DISPLAY NAMES.
122 ])
123 AT_CHECK([pspp -O format=csv sysfile-info.sps], [0], [dnl
124 Table: Variables
125 Name
126 x
127 name
128 ])
129 AT_CLEANUP
130
131 AT_SETUP([DISPLAY LABELS])
132 AT_DATA([sysfile-info.sps], [dnl
133 DATA LIST LIST NOTABLE /x * name (a10) .
134 VARIABLE LABEL x 'variable one' name 'variable two'.
135 VALUE LABEL x 1 'asdf' 2 'jkl;'.
136 DISPLAY LABELS.
137 ])
138 AT_CHECK([pspp -O format=csv sysfile-info.sps], [0], [dnl
139 Table: Variables
140 Name,Position,Label
141 x,1,variable one
142 name,2,variable two
143 ])
144 AT_CLEANUP
145
146 dnl DISPLAY VARIABLES Is tested in multiple places.