Merge remote-tracking branch 'origin/master' into sheet
[pspp] / tests / language / dictionary / value-labels.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([VALUE LABELS])
18
19 AT_SETUP([VALUE LABELS date formats])
20 AT_DATA([value-labels.sps], [dnl
21 DATA LIST LIST NOTABLE /ad (adate10) dt (datetime20).
22 VALUE LABELS ad 'july 10, 1982' 'label 1'
23                 '1-2-93' 'label 2'
24                 '5-4-2003' 'label 3'
25             /dt '12 Apr 2011 06:09:56' 'label 4'.
26 DISPLAY DICTIONARY.
27 ])
28 AT_CHECK([pspp -O format=csv value-labels.sps], [0], [dnl
29 Variable,Description,Position
30 ad,"Format: ADATE10
31
32 Value,Label
33 07/10/1982,label 1
34 01/02/1993,label 2
35 05/04/2003,label 3",1
36 dt,"Format: DATETIME20.0
37
38 Value,Label
39 12-APR-2011 06:09:56,label 4",2
40 ])
41 AT_CLEANUP
42
43 AT_SETUP([VALUE LABELS with new-line])
44 AT_DATA([value-labels.sps], [dnl
45 DATA LIST LIST NOTABLE /x.
46 VALUE LABELS x 1 'one' 2 'first line\nsecond line' 3 'three'.
47 BEGIN DATA.
48 1
49 2
50 3
51 END DATA.
52 DISPLAY DICTIONARY.
53 FREQUENCIES x/STAT=NONE.
54 ])
55 AT_CHECK([pspp -O format=csv value-labels.sps], [0], [dnl
56 Variable,Description,Position
57 x,"Format: F8.2
58
59 Value,Label
60 1.00,one
61 2.00,first line\nsecond line
62 3.00,three",1
63
64 Table: x
65 Value Label,Value,Frequency,Percent,Valid Percent,Cum Percent
66 one,1.00,1,33.33,33.33,33.33
67 "first line
68 second line",2.00,1,33.33,33.33,66.67
69 three,3.00,1,33.33,33.33,100.00
70 Total,,3,100.0,100.0,
71 ])
72 AT_CLEANUP
73
74 AT_SETUP([VALUE LABELS with new-line in system file])
75 AT_DATA([save.sps], [dnl
76 DATA LIST LIST NOTABLE /x.
77 VALUE LABELS x 1 'one' 2 'first line\nsecond line' 3 'three'.
78 BEGIN DATA.
79 1
80 2
81 3
82 END DATA.
83 SAVE OUTFILE='value-labels.sav'.
84 ])
85 AT_CHECK([pspp -O format=csv save.sps])
86 AT_DATA([get.sps], [dnl
87 GET FILE='value-labels.sav'.
88 DISPLAY DICTIONARY.
89 FREQUENCIES x/STAT=NONE.
90 ])
91 AT_CHECK([pspp -O format=csv get.sps], [0], [dnl
92 Variable,Description,Position
93 x,"Format: F8.2
94
95 Value,Label
96 1.00,one
97 2.00,first line\nsecond line
98 3.00,three",1
99
100 Table: x
101 Value Label,Value,Frequency,Percent,Valid Percent,Cum Percent
102 one,1.00,1,33.33,33.33,33.33
103 "first line
104 second line",2.00,1,33.33,33.33,66.67
105 three,3.00,1,33.33,33.33,100.00
106 Total,,3,100.0,100.0,
107 ])
108 AT_CLEANUP
109
110 dnl Tests for a bug which caused VALUE LABELS to 
111 dnl crash when given invalid syntax.
112 AT_SETUP([VALUE LABELS invalid syntax bug])
113 AT_DATA([value-labels.sps], [dnl
114 DATA LIST LIST NOTABLE /a * pref * .
115 BEGIN DATA.
116     1.00     1.00    
117     1.00     2.00    
118     2.00     1.00    
119     2.00     2.00    
120 END DATA.
121
122 VALUE LABELS /var=a 'label for a'.
123 ])
124 AT_CHECK([pspp -O format=csv value-labels.sps], [1], [dnl
125 value-labels.sps:9: error: VALUE LABELS: var is not a variable name.
126 ])
127 AT_CLEANUP
128
129 # Tests for a bug which caused a crash if VALUE LABELS had a trailing /.
130 AT_SETUP([VALUE LABELS trailing `/' bug])
131 AT_DATA([value-labels.sps], [dnl
132 DATA LIST LIST NOTABLE /X * .
133 BEGIN DATA.
134
135 2
136 3
137 4
138 END DATA.
139
140
141 VALUE LABELS X 1 'one' 2 'two' 3 'three'/
142
143
144 LIST VARIABLES=X.
145 ])
146 AT_CHECK([pspp -O format=csv value-labels.sps], [0], [dnl
147 Table: Data List
148 X
149 1.00
150 2.00
151 3.00
152 4.00
153 ])
154 AT_CLEANUP