More READ negative tests.
authorBen Pfaff <blp@cs.stanford.edu>
Sat, 6 Nov 2021 18:52:27 +0000 (11:52 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Sat, 6 Nov 2021 18:52:27 +0000 (11:52 -0700)
src/language/stats/matrix.c
tests/language/stats/matrix.at

index 28ad99ba12241eb31f81fef526c32dfc47f362b9..9d053374de22f98a808fd59c617a48b707aca2d9 100644 (file)
@@ -4908,7 +4908,9 @@ matrix_cmd_execute_read (struct read_command *read)
 
       if (d[0] < 0 || d[0] > SIZE_MAX || d[1] < 0 || d[1] > SIZE_MAX)
         {
-          msg (SE, _("SIZE (%g,%g) is outside valid range."), d[0], d[1]);
+          msg (SE, _("Matrix dimensions %g×%g specified on SIZE "
+                     "are outside valid range."),
+               d[0], d[1]);
           free (iv0.indexes);
           free (iv1.indexes);
           return;
@@ -4941,8 +4943,8 @@ matrix_cmd_execute_read (struct read_command *read)
         {
           if (size[0] != submatrix_size[0] || size[1] != submatrix_size[1])
             {
-              msg (SE, _("SIZE (%zu,%zu) differs from submatrix dimensions "
-                         "%zu×%zu."),
+              msg (SE, _("Matrix dimensions %zu×%zu specified on SIZE "
+                         "differ from submatrix dimensions %zu×%zu."),
                    size[0], size[1],
                    submatrix_size[0], submatrix_size[1]);
               free (iv0.indexes);
index 9b86dc874bf2fcaaa3ecaec5cd2031837a5acfdb..8f1dba5d7f7d950958091a4e5a5229a6d9f1240a 100644 (file)
@@ -2605,30 +2605,106 @@ AT_CLEANUP
 AT_SETUP([MATRIX - READ - negative])
 AT_DATA([matrix.sps], [dnl
 MATRIX.
-READ ().
-READ x/FILE=().
-READ x/ENCODING=().
-READ x/FIELD=().
-READ x/FIELD=1 ().
-READ x/FIELD=1 TO ().
+READ !.
+READ x/FILE=!.
+READ x/ENCODING=!.
+READ x/FIELD=!.
+READ x/FIELD=1 !.
+READ x/FIELD=1 TO !.
 READ x/FIELD=1 TO 0.
-READ x/FIELD=1 TO 10 BY ().
+READ x/FIELD=1 TO 10 BY !.
 READ x/FIELD=1 TO 10 BY 6.
-READ x/SIZE=().
-READ x/MODE=().
-READ x/FORMAT=().
+READ x/SIZE=!.
+READ x/MODE=!.
+READ x/FORMAT=!.
 READ x/FORMAT=F8.2/FORMAT=F8.2.
 READ x/FORMAT='5XYZZY'.
 READ x/FORMAT=XYZZY.
-READ x/().
+READ x/!.
 READ x.
 READ x/FIELD=1 TO 10.
 READ x/FIELD=1 TO 10/SIZE={1,2}.
 READ x/FIELD=1 TO 10/SIZE={1,2}/FILE='xyzzy.txt'/FORMAT='15F'.
 READ x/FIELD=1 TO 10 BY 2/SIZE={1,2}/FILE='xyzzy.txt'/FORMAT=F5.
 READ x/FIELD=1 TO 10 BY 2/SIZE={1,2}/FILE='xyzzy.txt'/FORMAT='2F'.
+READ x/FIELD=1 TO 10/SIZE={1,2;3,4}/FILE='matrix.txt'.
+READ x/FIELD=1 TO 10/SIZE={1,2,3}/FILE='matrix.txt'.
+READ x/FIELD=1 TO 10/SIZE={-1}/FILE='matrix.txt'.
+COMPUTE x={1,2,3}.
+READ x(:,:)/FIELD=1 TO 10/SIZE={2,2}/FILE='matrix.txt'.
+READ x/FIELD=1 TO 10/SIZE={1,3}/FILE='matrix.txt'/MODE=SYMMETRIC.
 END MATRIX.
 ])
-AT_CHECK([pspp matrix.sps], [0], [])
+AT_DATA([matrix.txt], [])
+AT_CHECK([pspp matrix.sps], [1], [dnl
+matrix.sps:2.6: error: READ: Syntax error at `!': expecting identifier.
+
+matrix.sps:3.13: error: READ: Syntax error at `!': expecting a file name or
+handle name.
+
+matrix.sps:4.17: error: READ: Syntax error at `!': expecting string.
+
+matrix.sps:5.14: error: READ: Syntax error at `!': Expected positive integer
+for FIELD.
+
+matrix.sps:6.16: error: READ: Syntax error at `!': expecting `TO'.
+
+matrix.sps:7.19: error: READ: Syntax error at `!': Expected positive integer
+for TO.
+
+matrix.sps:8.19: error: READ: Syntax error at `0': Expected positive integer
+for TO.
+
+matrix.sps:9.25: error: READ: Syntax error at `!': Expected integer between 1
+and 10 for BY.
+
+matrix.sps:10: error: READ: BY 6 does not evenly divide record width 10.
+
+matrix.sps:11.13: error: READ: Syntax error at `!'.
+
+matrix.sps:12.13: error: READ: Syntax error at `!': expecting RECTANGULAR or
+SYMMETRIC.
+
+matrix.sps:13.15: error: READ: Syntax error at `!': expecting identifier.
+
+matrix.sps:14: error: READ: Subcommand FORMAT may only be specified once.
+
+matrix.sps:15.15-15.22: error: READ: Syntax error at `'5XYZZY'': Unknown format
+XYZZY.
+
+matrix.sps:16: error: READ: Unknown format type `XYZZY'.
+
+matrix.sps:17.8: error: READ: Syntax error at `!': expecting FILE, FIELD, MODE,
+REREAD, or FORMAT.
+
+matrix.sps:18: error: READ: Required subcommand FIELD was not specified.
+
+matrix.sps:19: error: READ: SIZE is required for reading data into a full
+matrix (as opposed to a submatrix).
+
+matrix.sps:20: error: READ: Required subcommand FILE was not specified.
+
+matrix.sps:21: error: READ: 15 repetitions cannot fit in record width 10.
+
+matrix.sps:22: error: READ: FORMAT specifies field width 5 but BY specifies 2.
+
+matrix.sps:23: error: READ: FORMAT specifies 2 repetitions with record width
+10, which implies field width 5, but BY specifies field width 2.
+
+matrix.sps:24: error: MATRIX: SIZE must evaluate to a scalar or a 2-element
+vector, not a 2×2 matrix.
+
+matrix.sps:25: error: MATRIX: SIZE must evaluate to a scalar or a 2-element
+vector, not a 1×3 matrix.
+
+matrix.sps:26: error: MATRIX: Matrix dimensions -1×1 specified on SIZE are
+outside valid range.
+
+matrix.sps:28: error: MATRIX: Matrix dimensions 2×2 specified on SIZE differ
+from submatrix dimensions 1×3.
+
+matrix.sps:29: error: MATRIX: Cannot read non-square 1×3 matrix using READ with
+MODE=SYMMETRIC.
+])
 AT_CLEANUP