More MATRIX SAVE negative tests.
authorBen Pfaff <blp@cs.stanford.edu>
Tue, 9 Nov 2021 06:55:13 +0000 (22:55 -0800)
committerBen Pfaff <blp@cs.stanford.edu>
Tue, 9 Nov 2021 06:55:13 +0000 (22:55 -0800)
src/language/stats/matrix.c
tests/language/stats/matrix.at

index a145282b1237575e73215d5469a5540d37f22e0f..32a06914d927780eeebde185896c41da35a6428c 100644 (file)
@@ -4475,14 +4475,20 @@ save_file_open (struct save_file *sf, gsl_matrix *m)
 
   if (!stringi_set_is_empty (&strings))
     {
+      size_t count = stringi_set_count (&strings);
       const char *example = stringi_set_node_get_string (
         stringi_set_first (&strings));
-      msg (ME, ngettext ("STRINGS specified a variable %s, but no variable "
-                         "with that name was found on SAVE.",
-                         "STRINGS specified %2$zu variables, including %1$s, "
-                         "whose names were not found on SAVE.",
-                         stringi_set_count (&strings)),
-           example, stringi_set_count (&strings));
+
+      if (count == 1)
+        msg (ME, _("The SAVE command STRINGS subcommand specifies an unknown "
+                   "variable %s."), example);
+      else
+        msg (ME, ngettext ("The SAVE command STRINGS subcommand specifies %zu "
+                           "unknown variable: %s.",
+                           "The SAVE command STRINGS subcommand specifies %zu "
+                           "unknown variables, including %s.",
+                           count),
+             count, example);
       ok = false;
     }
   stringi_set_destroy (&strings);
index d55514c9dfe33b4d437eb6ec134be216f2638346..0db26d6eb495b6aeb209e3ee29c5eae2f52ce069 100644 (file)
@@ -3180,6 +3180,9 @@ SAVE 1.
 SAVE 1/OUTFILE='matrix.sav'/NAMES={'a'}/VARIABLES=a.
 SAVE 1/OUTFILE='matrix2.sav'.
 SAVE {1,2}/OUTFILE='matrix2.sav'.
+SAVE {1,2}/OUTFILE='matrix3.sav'/NAMES={'a', 'a'}.
+SAVE {1,2}/OUTFILE='matrix4.sav'/STRINGS=a.
+SAVE {1,2}/OUTFILE='matrix5.sav'/STRINGS=a, b.
 END MATRIX.
 ])
 AT_CHECK([pspp matrix.sps], [1], [dnl
@@ -3202,5 +3205,12 @@ NAMES.
 
 error: The first SAVE to `matrix2.sav' within this matrix program had 1
 columns, so a 1×2 matrix cannot be saved to it.
+
+error: Duplicate variable name a in SAVE statement.
+
+error: The SAVE command STRINGS subcommand specifies an unknown variable a.
+
+error: The SAVE command STRINGS subcommand specifies 2 unknown variables,
+including a.
 ])
 AT_CLEANUP
\ No newline at end of file