Fixed crash in two sample npar tests with (paired)
authorJohn Darrington <john@darrington.wattle.id.au>
Fri, 6 Jul 2012 14:30:14 +0000 (16:30 +0200)
committerJohn Darrington <john@darrington.wattle.id.au>
Fri, 6 Jul 2012 14:30:14 +0000 (16:30 +0200)
This change fixes a bug where an assertion would
fire if a two sample npar test was given where
a variable appeared twice in a variable list.

src/language/stats/npar.c
tests/language/stats/npar.at

index e277d36acccd887eee8687b925943634e0484a9e..af41b104731665e4adb4202d609de00fa8f77a7d 100644 (file)
@@ -1080,7 +1080,7 @@ parse_two_sample_related_test (struct lexer *lexer,
   if (!parse_variables_const_pool (lexer, pool,
                                   dict,
                                   &vlist1, &n_vlist1,
-                                  PV_NUMERIC | PV_NO_SCRATCH | PV_NO_DUPLICATE) )
+                                  PV_NUMERIC | PV_NO_SCRATCH | PV_DUPLICATE) )
     return false;
 
   if ( lex_match (lexer, T_WITH))
@@ -1088,7 +1088,7 @@ parse_two_sample_related_test (struct lexer *lexer,
       with = true;
       if ( !parse_variables_const_pool (lexer, pool, dict,
                                        &vlist2, &n_vlist2,
-                                       PV_NUMERIC | PV_NO_SCRATCH | PV_NO_DUPLICATE) )
+                                       PV_NUMERIC | PV_NO_SCRATCH | PV_DUPLICATE) )
        return false;
 
       paired = (lex_match (lexer, T_LPAREN) &&
@@ -1101,9 +1101,12 @@ parse_two_sample_related_test (struct lexer *lexer,
       if (paired)
        {
          if ( n_vlist1 != n_vlist2)
-           msg (SE, _("PAIRED was specified but the number of variables "
+            {
+             msg (SE, _("PAIRED was specified but the number of variables "
                       "preceding WITH (%zu) did not match the number "
                       "following (%zu)."), n_vlist1, n_vlist2);
+              return false;
+            }
 
          test_parameters->n_pairs = n_vlist1 ;
        }
index f92af07ec89ae475e31492f57c439edc8ed42b3c..38e2e7c4c1520e164855fcd22f8ba9be94a34729 100644 (file)
@@ -1625,3 +1625,41 @@ x,4,24.000,29.500,65.000,15.902,-2.232,.026
 ])
 
 AT_CLEANUP
+
+dnl Checks that (PAIRED) can have lists where the same 
+dnl variable appears more than once.
+AT_SETUP([NPAR TESTS (PAIRED)])
+AT_DATA([npar.sps], [dnl
+set format = F12.3.
+data list notable list /a * b * c *.
+begin data.
+1 2 4
+4 5 3
+1 2 2
+4 5 1
+end data.
+
+npar tests /wilcoxon a b with c c (paired).
+])
+
+AT_CHECK([pspp -O format=csv npar.sps], [0], [dnl
+Table: Ranks
+,,N,Mean Rank,Sum of Ranks
+a - c,Negative Ranks,2,2.500,5.000
+,Positive Ranks,2,2.500,5.000
+,Ties,0,,
+,Total,4,,
+b - c,Negative Ranks,1,1.500,1.500
+,Positive Ranks,2,2.250,4.500
+,Ties,1,,
+,Total,4,,
+
+Table: Test Statistics
+,a - c,b - c
+Z,.000,-.816
+Asymp. Sig. (2-tailed),1.000,.414
+])
+
+
+AT_CLEANUP
+