MEANS: Improve error messages and coding style.
[pspp] / tests / language / data-io / print.at
index 02c18c619f2e3513268291e9c283ec2ea758be87..75ac1d03eb8339a59046410524071dedcaaf5531 100644 (file)
@@ -1,16 +1,16 @@
 dnl PSPP - a program for statistical analysis.
 dnl Copyright (C) 2017 Free Software Foundation, Inc.
-dnl 
+dnl
 dnl This program is free software: you can redistribute it and/or modify
 dnl it under the terms of the GNU General Public License as published by
 dnl the Free Software Foundation, either version 3 of the License, or
 dnl (at your option) any later version.
-dnl 
+dnl
 dnl This program is distributed in the hope that it will be useful,
 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 dnl GNU General Public License for more details.
-dnl 
+dnl
 dnl You should have received a copy of the GNU General Public License
 dnl along with this program.  If not, see <http://www.gnu.org/licenses/>.
 dnl
@@ -57,50 +57,36 @@ AT_CHECK([pspp -O format=csv print.sps], [0], [dnl
 
 
 12
-
 1 -2 @&t@
 
-
-
 3 4 @&t@
 
 
 
 34
-
 3 -4 @&t@
 
-
-
 . 6 @&t@
 
 
 
 .6
-
 . -6 @&t@
 
-
-
 7 . @&t@
 
 
 
 7.
-
 7 -. @&t@
 
-
-
 9 0 @&t@
 
 
 
 90
-
 9 -0 @&t@
 
-
 ])
 AT_CLEANUP
 
@@ -188,7 +174,9 @@ PRINT F8.2
 LIST.
 ])
 AT_CHECK([pspp -O format=csv print.sps], [1], [dnl
-print.sps:7.7-7.10: error: PRINT: Syntax error at `F8.2': expecting a valid subcommand.
+"print.sps:7.7-7.10: error: PRINT: Syntax error expecting OUTFILE, ENCODING, RECORDS, TABLE, or NOTABLE.
+    7 | PRINT F8.2
+      |       ^~~~"
 
 Table: Data List
 a,b
@@ -351,3 +339,60 @@ AT_CHECK([tr '\r' R < crlf.txt], [0], [dnl
  5 R
 ])
 AT_CLEANUP
+
+AT_SETUP([PRINT syntax errors])
+AT_DATA([print.sps], [dnl
+DATA LIST LIST NOTABLE /x.
+PRINT OUTFILE=**.
+PRINT ENCODING=**.
+PRINT RECORDS=-1.
+PRINT **.
+PRINT/ **.
+PRINT/'string' 0.
+PRINT/'string' 5-3.
+PRINT/y.
+PRINT/x 0.
+PRINT/x (A8).
+])
+AT_CHECK([pspp -O format=csv print.sps], [1], [dnl
+"print.sps:2.15-2.16: error: PRINT: Syntax error expecting a file name or handle name.
+    2 | PRINT OUTFILE=**.
+      |               ^~"
+
+"print.sps:3.16-3.17: error: PRINT: Syntax error expecting string.
+    3 | PRINT ENCODING=**.
+      |                ^~"
+
+"print.sps:4.15-4.16: error: PRINT: Syntax error expecting non-negative integer for RECORDS.
+    4 | PRINT RECORDS=-1.
+      |               ^~"
+
+"print.sps:5.7-5.8: error: PRINT: Syntax error expecting OUTFILE, ENCODING, RECORDS, TABLE, or NOTABLE.
+    5 | PRINT **.
+      |       ^~"
+
+"print.sps:6.8-6.9: error: PRINT: Syntax error expecting variable name.
+    6 | PRINT/ **.
+      |        ^~"
+
+"print.sps:7.16: error: PRINT: Column positions for fields must be positive.
+    7 | PRINT/'string' 0.
+      |                ^"
+
+"print.sps:8.16-8.18: error: PRINT: The ending column for a field must be greater than the starting column.
+    8 | PRINT/'string' 5-3.
+      |                ^~~"
+
+"print.sps:9.7: error: PRINT: y is not a variable name.
+    9 | PRINT/y.
+      |       ^"
+
+"print.sps:10.9: error: PRINT: Column positions for fields must be positive.
+   10 | PRINT/x 0.
+      |         ^"
+
+"print.sps:11.9-11.12: error: PRINT: Numeric variable x is not compatible with string format A8.
+   11 | PRINT/x (A8).
+      |         ^~~~"
+])
+AT_CLEANUP