FACTOR: Improve error messages and coding style.
[pspp] / tests / language / stats / crosstabs.at
index 91ff4393eec04fbb7ff12ab4a96e9fbd9cd3864a..a26379e88af7337aa8cafbca9868414118fcd121 100644 (file)
@@ -16,6 +16,67 @@ dnl along with this program.  If not, see <http://www.gnu.org/licenses/>.
 dnl
 AT_BANNER([CROSSTABS procedure])
 
+dnl Based on bug #60982.
+AT_SETUP([CROSSTABS residuals])
+AT_DATA([crosstabs.sps],
+  [DATASET CLOSE ALL.
+DATA LIST LIST NOTABLE/ r c n.
+BEGIN DATA
+1 1 26
+1 2 31
+2 1 12
+2 2 32
+3 1 27
+3 2 18
+4 1 8
+4 2 7
+END DATA.
+WEIGHT by n.
+CROSSTABS r by c /STATISTICS=CHISQ
+/CELLS=COUNT EXPECTED RESID SRESID ASRESID.
+])
+AT_CHECK([pspp -O format=csv crosstabs.sps], [0],
+  [Table: Summary
+,Cases,,,,,
+,Valid,,Missing,,Total,
+,N,Percent,N,Percent,N,Percent
+r × c,161.00,100.0%,.00,.0%,161.00,100.0%
+
+Table: r × c
+,,,c,,Total
+,,,1.00,2.00,
+r,1.00,Count,26.00,31.00,57.00
+,,Expected,25.84,31.16,.35
+,,Residual,.16,-.16,
+,,Std. Residual,.03,-.03,
+,,Adjusted Residual,.05,-.05,
+,2.00,Count,12.00,32.00,44.00
+,,Expected,19.95,24.05,.27
+,,Residual,-7.95,7.95,
+,,Std. Residual,-1.78,1.62,
+,,Adjusted Residual,-2.82,2.82,
+,3.00,Count,27.00,18.00,45.00
+,,Expected,20.40,24.60,.28
+,,Residual,6.60,-6.60,
+,,Std. Residual,1.46,-1.33,
+,,Adjusted Residual,2.33,-2.33,
+,4.00,Count,8.00,7.00,15.00
+,,Expected,6.80,8.20,.09
+,,Residual,1.20,-1.20,
+,,Std. Residual,.46,-.42,
+,,Adjusted Residual,.65,-.65,
+Total,,Count,73.00,88.00,161.00
+,,Expected,.45,.55,1.00
+
+Table: Chi-Square Tests
+,Value,df,Asymptotic Sig. (2-tailed)
+Pearson Chi-Square,10.09,3.00,.018
+Likelihood Ratio,10.35,3.00,.016
+Linear-by-Linear Association,1.96,1.00,.162
+N of Valid Cases,161.00,,
+])
+AT_CLEANUP
+
 AT_SETUP([CROSSTABS integer mode crash])
 AT_DATA([crosstabs.sps],
   [DATA LIST LIST /A * B * X * Y * .
@@ -254,7 +315,7 @@ SPLIT FILE SEPARATE BY v0.
 
 CROSSTABS
     /TABLES= v1 BY v2
-    /FORMAT=AVALUE TABLES PIVOT
+    /FORMAT=AVALUE TABLES
     /STATISTICS=CHISQ
     /CELLS=COUNT ROW COLUMN TOTAL.
 ])
@@ -621,7 +682,9 @@ Table: Summary
 ,N,Percent,N,Percent,N,Percent
 X1 × X2,0,.0%,1,100.0%,1,100.0%
 
-crosstabs.sps:8: warning: CROSSTABS: Crosstabulation X1 × X2 contained no non-missing cases.
+"crosstabs.sps:8.20-8.27: warning: CROSSTABS: Crosstabulation X1 × X2 contained no non-missing cases.
+    8 | CROSSTABS /TABLES= X1 by X2.
+      |                    ^~~~~~~~"
 ])
 AT_CLEANUP
 
@@ -1659,7 +1722,7 @@ end data.
 weight by w.
 
 crosstabs /table = p1 by p2
-       statistics = kappa
+       /statistics = kappa
        .
 ])
 
@@ -1876,3 +1939,93 @@ AT_CHECK([test -e xxx-2.png], [0], [ignore])
 AT_CHECK([diff xxx-1.png xxx-2.png], [0], [ignore])
 
 AT_CLEANUP
+
+AT_SETUP([CROSSTABS syntax errors])
+AT_DATA([crosstabs.sps], [dnl
+DATA LIST LIST NOTABLE/x y v1 to v100.
+CROSSTABS TABLES=x BY y/VARIABLES **.
+CROSSTABS VARIABLES=**.
+CROSSTABS VARIABLES=x **.
+CROSSTABS VARIABLES=x (**).
+CROSSTABS VARIABLES=x (1,**).
+CROSSTABS VARIABLES=x (1,5**).
+CROSSTABS MISSING=**.
+CROSSTABS COUNT=**.
+CROSSTABS FORMAT=**.
+CROSSTABS CELLS=**.
+CROSSTABS STATISTICS=**.
+CROSSTABS **.
+CROSSTABS
+       v1 to v100 BY v1 to v100 BY v1 to v100 BY v1 to v100 BY v1 to v100 BY v1 to v100
+    BY v1 to v100 BY v1 to v100 BY v1 to v100 BY v1 to v100 BY v1 to v100 BY v1 to v100
+    BY v1 to v100 BY v1 to v100 BY v1 to v100 BY v1 to v100 BY v1 to v100 BY v1 to v100
+    BY v1 to v100 BY v1 to v100 BY v1 to v100 BY v1 to v100 BY v1 to v100 BY v1 to v100
+    BY v1 to v100 BY v1 to v100 BY v1 to v100 BY v1 to v100 BY v1 to v100 BY v1 to v100
+    BY v1 to v100 BY v1 to v100 BY v1 to v100 BY v1 to v100 BY v1 to v100 BY v1 to v100.
+CROSSTABS BARCHART.
+CROSSTABS x BY y/MISSING=REPORT.
+])
+AT_CHECK([pspp -O format=csv crosstabs.sps], [1], [dnl
+"crosstabs.sps:2.25-2.33: error: CROSSTABS: VARIABLES must be specified before TABLES.
+    2 | CROSSTABS TABLES=x BY y/VARIABLES **.
+      |                         ^~~~~~~~~"
+
+"crosstabs.sps:3.21-3.22: error: CROSSTABS: Syntax error expecting variable name.
+    3 | CROSSTABS VARIABLES=**.
+      |                     ^~"
+
+"crosstabs.sps:4.23-4.24: error: CROSSTABS: Syntax error expecting `('.
+    4 | CROSSTABS VARIABLES=x **.
+      |                       ^~"
+
+"crosstabs.sps:5.24-5.25: error: CROSSTABS: Syntax error expecting integer.
+    5 | CROSSTABS VARIABLES=x (**).
+      |                        ^~"
+
+"crosstabs.sps:6.26-6.27: error: CROSSTABS: Syntax error expecting positive integer.
+    6 | CROSSTABS VARIABLES=x (1,**).
+      |                          ^~"
+
+"crosstabs.sps:7.27-7.28: error: CROSSTABS: Syntax error expecting `)'.
+    7 | CROSSTABS VARIABLES=x (1,5**).
+      |                           ^~"
+
+"crosstabs.sps:8.19-8.20: error: CROSSTABS: Syntax error expecting TABLE, INCLUDE, or REPORT.
+    8 | CROSSTABS MISSING=**.
+      |                   ^~"
+
+"crosstabs.sps:9.17-9.18: error: CROSSTABS: Syntax error expecting ASIS, CASE, CELL, ROUND, or TRUNCATE.
+    9 | CROSSTABS COUNT=**.
+      |                 ^~"
+
+"crosstabs.sps:10.18-10.19: error: CROSSTABS: Syntax error expecting AVALUE, DVALUE, TABLES, or NOTABLES.
+   10 | CROSSTABS FORMAT=**.
+      |                  ^~"
+
+"crosstabs.sps:11.17-11.18: error: CROSSTABS: Syntax error expecting COUNT, EXPECTED, ROW, COLUMN, TOTAL, RESIDUAL, SRESIDUAL, or ASRESIDUAL.
+   11 | CROSSTABS CELLS=**.
+      |                 ^~"
+
+"crosstabs.sps:12.22-12.23: error: CROSSTABS: Syntax error expecting one of the following: CHISQ, PHI, CC, LAMBDA, UC, BTAU, CTAU, RISK, GAMMA, D, KAPPA, ETA, CORR.
+   12 | CROSSTABS STATISTICS=**.
+      |                      ^~"
+
+"crosstabs.sps:13.11-13.12: error: CROSSTABS: Syntax error expecting subcommand name or variable name.
+   13 | CROSSTABS **.
+      |           ^~"
+
+"crosstabs.sps:15.8-16.59: error: CROSSTABS: Too many cross-tabulation variables or dimensions.
+   15 |        v1 to v100 BY v1 to v100 BY v1 to v100 BY v1 to v100 BY v1 to v100 BY v1 to v100
+      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+   16 |     BY v1 to v100 BY v1 to v100 BY v1 to v100 BY v1 to v100 BY v1 to v100 BY v1 to v100
+      | -----------------------------------------------------------"
+
+crosstabs.sps:21: error: CROSSTABS: At least one crosstabulation must be requested (using the TABLES subcommand).
+
+"crosstabs.sps:22.26-22.31: warning: CROSSTABS: Missing mode REPORT not allowed in general mode.  Assuming MISSING=TABLE.
+   22 | CROSSTABS x BY y/MISSING=REPORT.
+      |                          ^~~~~~"
+
+error: CROSSTABS: At end of input: Syntax error expecting `BEGIN DATA'.
+])
+AT_CLEANUP
\ No newline at end of file