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