TITLE and SUBTITLE: Don't treat an unquoted argument as a quoted string.
[pspp] / tests / language / utilities / title.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([TITLE and related commands])
18
19 AT_SETUP([FILE LABEL and (ADD) DOCUMENT])
20 AT_DATA([file-label.sps], [dnl
21 /* Set up a dummy active dataset in memory.
22 data list /X 1 Y 2.
23 begin data.
24 16
25 27
26 38
27 49
28 50
29 end data.
30
31 /* Add value labels for some further testing of value labels.
32 value labels x y 1 'first label' 2 'second label' 3 'third label'.
33 add value labels x 1 'first label mark two'.
34
35 /* Add a file label and a few documents.
36 file label This is a test file label.
37 document First line of a document
38 Second line of a document
39 The last line should end with a period: .
40
41
42 /* Display the documents.
43 display documents.
44 display file label.
45
46 ADD DOCUMENT 'Line one' 'Line two'.
47
48 /* Save the active dataset then get it and display the documents again.
49 save /OUTFILE='foo.save'.
50 get /FILE='foo.save'.
51 display documents.
52 display file label.
53
54 /* There is an interesting interaction that occurs if the 'execute'
55 /* command below.  What happens is that an error message is output
56 /* at the next 'save' command that 'foo.save' is already open for
57 /* input.  This is because the 'get' hasn't been executed yet and
58 /* therefore PSPP would be reading from and writing to the same
59 /* file at once, which is obviously a Bad Thing.  But 'execute'
60 /* here clears up that potential problem.
61 execute.
62
63 /* Add another (shorter) document and try again.
64 document There should be another document now.
65 display documents.
66
67 /* Save and get.
68 save /OUTFILE='foo.save'.
69 get /FILE='foo.save'.
70 display documents.
71 display file label.
72
73 /* Done.
74 ])
75 AT_CHECK([pspp -o pspp.csv file-label.sps])
76 dnl Filter out the dates/times
77 AT_CHECK([[sed 's/(Entered [^)]*)/(Entered <date>)/' pspp.csv]], [0], [dnl
78 Table: Reading 1 record from INLINE.
79 Variable,Record,Columns,Format
80 X,1,1-1,F1.0
81 Y,1,2-2,F1.0
82
83 Table: Documents
84 "document First line of a document
85 Second line of a document
86 The last line should end with a period: .
87    (Entered <date>)"
88
89 Table: File Label
90 Label,This is a test file label
91
92 Table: Documents
93 "document First line of a document
94 Second line of a document
95 The last line should end with a period: .
96    (Entered <date>)
97 Line one
98 Line two
99    (Entered <date>)"
100
101 Table: File Label
102 Label,This is a test file label
103
104 Table: Documents
105 "document First line of a document
106 Second line of a document
107 The last line should end with a period: .
108    (Entered <date>)
109 Line one
110 Line two
111    (Entered <date>)
112 document There should be another document now.
113    (Entered <date>)"
114
115 Table: Documents
116 "document First line of a document
117 Second line of a document
118 The last line should end with a period: .
119    (Entered <date>)
120 Line one
121 Line two
122    (Entered <date>)
123 document There should be another document now.
124    (Entered <date>)"
125
126 Table: File Label
127 Label,This is a test file label
128 ])
129 AT_CLEANUP
130
131 AT_SETUP([TITLE and SUBTITLE])
132 for command in TITLE SUBTITLE; do
133     cat >title.sps <<EOF
134 $command foo  bar.
135 SHOW $command.
136
137 $command 'foo bar baz quux'.
138 SHOW $command.
139 EOF
140     cat >expout <<EOF
141 title.sps:2: note: SHOW: $command is foo  bar.
142
143 title.sps:5: note: SHOW: $command is foo bar baz quux.
144 EOF
145     AT_CHECK([pspp -O format=csv title.sps], [0], [expout])
146 done
147 AT_CLEANUP