CORRELATIONS: Improve error messages and coding style.
[pspp] / tests / language / stats / reliability.at
index f320d3e6f38246772e474e4e43c3173b541f2d8d..832da73eb86cf93e7e14f8c2e6859d73d913e519 100644 (file)
@@ -1,3 +1,19 @@
+dnl PSPP - a program for statistical analysis.
+dnl Copyright (C) 2017 Free Software Foundation, Inc.
+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 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 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
 AT_BANNER([RELIABILITY])
 
 AT_SETUP([RELIABILITY])
@@ -173,24 +189,29 @@ RELIABILITY
 
 RELIABILITY
   /VARIABLES=var2 var6 var8 var15 var17 var19
-  /SCALE('Totals') var6 var8 var15 var17 
+  /SCALE('Totals') var6 var8 var15 var17
   /SUMMARY = total
+  /STATISTICS = DESCRIPTIVES COVARIANCES
  .
 
 
 RELIABILITY
-  /VARIABLES=var6 var8 var15 var17 
+  /VARIABLES=var6 var8 var15 var17
   .
 ])
-AT_CHECK([pspp -o pspp.csv reliability.sps])
+AT_CHECK([pspp -o pspp.csv -o pspp.txt reliability.sps], [0], [dnl
+reliability.sps:174.4-174.40: warning: RELIABILITY: The STATISTICS subcommand is not yet implemented.  No statistics will be produced.
+  174 |   /STATISTICS = DESCRIPTIVES COVARIANCES
+      |    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+])
 AT_CHECK([cat pspp.csv], [0], [dnl
 Scale: Everything
 
 Table: Case Processing Summary
-,,N,%
-Cases,Valid,131,92.91
-,Excluded,10,7.09
-,Total,141,100.00
+Cases,N,Percent
+Valid,131,92.9%
+Excluded,10,7.1%
+Total,141,100.0%
 
 Table: Reliability Statistics
 Cronbach's Alpha,N of Items
@@ -199,10 +220,10 @@ Cronbach's Alpha,N of Items
 Scale: Nothing
 
 Table: Case Processing Summary
-,,N,%
-Cases,Valid,131,92.91
-,Excluded,10,7.09
-,Total,141,100.00
+Cases,N,Percent
+Valid,131,92.9%
+Excluded,10,7.1%
+Total,141,100.0%
 
 Table: Reliability Statistics
 Cronbach's Alpha,Part 1,Value,.55
@@ -215,13 +236,17 @@ Spearman-Brown Coefficient,Equal Length,,.75
 ,Unequal Length,,.75
 Guttman Split-Half Coefficient,,,.75
 
+"reliability.sps:174.4-174.40: warning: RELIABILITY: The STATISTICS subcommand is not yet implemented.  No statistics will be produced.
+  174 |   /STATISTICS = DESCRIPTIVES COVARIANCES
+      |    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
+
 Scale: Totals
 
 Table: Case Processing Summary
-,,N,%
-Cases,Valid,131,92.91
-,Excluded,10,7.09
-,Total,141,100.00
+Cases,N,Percent
+Valid,131,92.9%
+Excluded,10,7.1%
+Total,141,100.0%
 
 Table: Reliability Statistics
 Cronbach's Alpha,N of Items
@@ -237,10 +262,10 @@ var17,16.60,8.00,.57,.67
 Scale: ANY
 
 Table: Case Processing Summary
-,,N,%
-Cases,Valid,131,92.91
-,Excluded,10,7.09
-,Total,141,100.00
+Cases,N,Percent
+Valid,131,92.9%
+Excluded,10,7.1%
+Total,141,100.0%
 
 Table: Reliability Statistics
 Cronbach's Alpha,N of Items
@@ -249,7 +274,7 @@ Cronbach's Alpha,N of Items
 AT_CLEANUP
 
 
-dnl This was causing a AT.  
+dnl This was causing a AT.
 AT_SETUP([RELIABILITY bad syntax])
 AT_DATA([bad-syntax.sps], [dnl
 data list notable list /x * y *.
@@ -268,3 +293,153 @@ reliability x y.
 AT_CHECK([pspp -O format=csv bad-syntax.sps], [1], [ignore])
 
 AT_CLEANUP
+
+dnl Checks for a crash when bad syntax followed scale specification.
+AT_SETUP([RELIABILITY bad syntax 2])
+AT_DATA([bad-syntax.sps], [dnl
+new file.
+data list notable list /f01 f02 f03 f04 f05 f06 f07 f08 f09 f10 *.
+begin data.
+end data.
+
+* This syntax is incorrect
+reliability variables=f01 to f10/asdfj.
+])
+AT_CHECK([pspp -O format=csv bad-syntax.sps], [1], [ignore])
+AT_CLEANUP
+
+
+dnl Checks for a crash when the active file was empty.  Bug #38660.
+AT_SETUP([RELIABILITY crash with no data])
+AT_DATA([reliability.sps], [dnl
+new file.
+data list notable list /f01 f02 f03 f04 f05 f06 f07 f08 f09 f10 *.
+begin data.
+end data.
+
+reliability variables=f01 to f10.
+])
+AT_CHECK([pspp -O format=csv reliability.sps], [0], [])
+AT_CLEANUP
+
+
+
+
+dnl This is an example from doc/tutorial.texi
+dnl So if the results of this have to be changed in any way,
+dnl make sure to update that file.
+AT_SETUP([RELIABILITY tutorial example])
+AT_DATA([tut-example.sps], [dnl
+get file='hotel.sav'.
+
+compute v3 = 6 - v3.
+compute v5 = 6 - v5.
+
+reliability variables = v1 v3 v4.
+])
+
+AT_CHECK([ln -s $top_srcdir/examples/hotel.sav .], [0])
+AT_CHECK([pspp -o pspp.csv -o pspp.txt tut-example.sps])
+AT_CHECK([cat pspp.csv], [0], [dnl
+Scale: ANY
+
+Table: Case Processing Summary
+Cases,N,Percent
+Valid,17,100.0%
+Excluded,0,.0%
+Total,17,100.0%
+
+Table: Reliability Statistics
+Cronbach's Alpha,N of Items
+.81,3
+])
+AT_CLEANUP
+
+AT_SETUP([RELIABILITY syntax errors])
+AT_DATA([reliability.sps], [dnl
+DATA LIST LIST NOTABLE/x y z.
+RELIABILITY **.
+RELIABILITY VARIABLES=**.
+RELIABILITY VARIABLES=x/ **.
+RELIABILITY VARIABLES=x y/SCALE **.
+RELIABILITY VARIABLES=x y/SCALE(**).
+RELIABILITY VARIABLES=x y/SCALE('a' **).
+RELIABILITY VARIABLES=x y/SCALE('a')=**.
+RELIABILITY VARIABLES=x y/MODEL SPLIT(**).
+RELIABILITY VARIABLES=x y/MODEL SPLIT(1 **).
+RELIABILITY VARIABLES=x y/MODEL **.
+RELIABILITY VARIABLES=x y/SUMMARY **.
+RELIABILITY VARIABLES=x y/MISSING=**.
+RELIABILITY VARIABLES=x y/STATISTICS=x y zz y/ **.
+RELIABILITY VARIABLES=x y/MODEL SPLIT(5).
+])
+AT_CHECK([pspp -O format=csv reliability.sps], [1], [dnl
+"reliability.sps:2.13-2.14: error: RELIABILITY: Syntax error expecting VARIABLES.
+    2 | RELIABILITY **.
+      |             ^~"
+
+"reliability.sps:3.23-3.24: error: RELIABILITY: Syntax error expecting variable name.
+    3 | RELIABILITY VARIABLES=**.
+      |                       ^~"
+
+"reliability.sps:4.23: warning: RELIABILITY: Reliability on a single variable is not useful.
+    4 | RELIABILITY VARIABLES=x/ **.
+      |                       ^"
+
+"reliability.sps:4.26-4.27: error: RELIABILITY: Syntax error expecting SCALE, MODEL, SUMMARY, MISSING, or STATISTICS.
+    4 | RELIABILITY VARIABLES=x/ **.
+      |                          ^~"
+
+"reliability.sps:5.33-5.34: error: RELIABILITY: Syntax error expecting `('.
+    5 | RELIABILITY VARIABLES=x y/SCALE **.
+      |                                 ^~"
+
+"reliability.sps:6.33-6.34: error: RELIABILITY: Syntax error expecting string.
+    6 | RELIABILITY VARIABLES=x y/SCALE(**).
+      |                                 ^~"
+
+"reliability.sps:7.37-7.38: error: RELIABILITY: Syntax error expecting `)'.
+    7 | RELIABILITY VARIABLES=x y/SCALE('a' **).
+      |                                     ^~"
+
+"reliability.sps:8.38-8.39: error: RELIABILITY: Syntax error expecting variable name.
+    8 | RELIABILITY VARIABLES=x y/SCALE('a')=**.
+      |                                      ^~"
+
+"reliability.sps:9.39-9.40: error: RELIABILITY: Syntax error expecting number.
+    9 | RELIABILITY VARIABLES=x y/MODEL SPLIT(**).
+      |                                       ^~"
+
+"reliability.sps:10.41-10.42: error: RELIABILITY: Syntax error expecting `@:}@'.
+   10 | RELIABILITY VARIABLES=x y/MODEL SPLIT(1 **).
+      |                                         ^~"
+
+"reliability.sps:11.33-11.34: error: RELIABILITY: Syntax error expecting ALPHA or SPLIT.
+   11 | RELIABILITY VARIABLES=x y/MODEL **.
+      |                                 ^~"
+
+"reliability.sps:12.35-12.36: error: RELIABILITY: Syntax error expecting TOTAL or ALL.
+   12 | RELIABILITY VARIABLES=x y/SUMMARY **.
+      |                                   ^~"
+
+"reliability.sps:13.35-13.36: error: RELIABILITY: Syntax error expecting INCLUDE or EXCLUDE.
+   13 | RELIABILITY VARIABLES=x y/MISSING=**.
+      |                                   ^~"
+
+"reliability.sps:14.27-14.45: warning: RELIABILITY: The STATISTICS subcommand is not yet implemented.  No statistics will be produced.
+   14 | RELIABILITY VARIABLES=x y/STATISTICS=x y zz y/ **.
+      |                           ^~~~~~~~~~~~~~~~~~~"
+
+"reliability.sps:14.48-14.49: error: RELIABILITY: Syntax error expecting SCALE, MODEL, SUMMARY, MISSING, or STATISTICS.
+   14 | RELIABILITY VARIABLES=x y/STATISTICS=x y zz y/ **.
+      |                                                ^~"
+
+"reliability.sps:15.39: error: RELIABILITY: The split point must be less than the number of variables.
+   15 | RELIABILITY VARIABLES=x y/MODEL SPLIT(5).
+      |                                       ^"
+
+"reliability.sps:15.23-15.25: note: RELIABILITY: There are 2 variables.
+   15 | RELIABILITY VARIABLES=x y/MODEL SPLIT(5).
+      |                       ^~~"
+])
+AT_CLEANUP
\ No newline at end of file