changeset 28526:1151ed869686

maint: merge stable to default.
author Kai T. Ohlhus <k.ohlhus@gmail.com>
date Thu, 02 Jul 2020 15:11:19 +0900
parents 455fe4a6f22c (current diff) 286fe9352cd6 (diff)
children d5311ca8f945
files libinterp/parse-tree/pt-eval.cc
diffstat 3 files changed, 28 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/parse-tree/pt-eval.cc	Wed Jul 01 15:33:53 2020 -0400
+++ b/libinterp/parse-tree/pt-eval.cc	Thu Jul 02 15:11:19 2020 +0900
@@ -1776,7 +1776,9 @@
                 for (octave_idx_type i = 0; i < tmp_ovl.length (); i++)
                   args.push_back (tmp_ovl(i));
               }
-            else if (tmp.is_defined ())
+            else if (! tmp.is_defined ())
+              error ("Element %d in argument list is not defined", k + 1);
+            else
               args.push_back (tmp);
           }
         else
--- a/scripts/testfun/assert.m	Wed Jul 01 15:33:53 2020 -0400
+++ b/scripts/testfun/assert.m	Thu Jul 02 15:11:19 2020 +0900
@@ -188,27 +188,27 @@
           err.observed{end+1} = ["O(" sprintf("%dx", size(cond))(1:end-1) ")"];
           err.expected{end+1} = ["E(" sprintf("%dx", size(expected))(1:end-1) ")"];
           err.reason{end+1} = "Structure sizes don't match";
+        elseif (! strcmp (sort (fieldnames (cond)),
+                          sort (fieldnames (expected))))
+          err.index{end+1} = ".";
+          err.observed{end+1} = "O";
+          err.expected{end+1} = "E";
+          err.reason{end+1} = "Structure fieldname mismatch";
         else
           try
-            empty = isempty (cond);
-            normal = (numel (cond) == 1);
-            for [v, k] = cond
-              if (! isfield (expected, k))
-                err.index{end+1} = ".";
-                err.observed{end+1} = "O";
-                err.expected{end+1} = "E";
-                err.reason{end+1} = ["'" k "'" " is not an expected field"];
-              endif
-              if (empty)
-                v = {};
-              elseif (normal)
-                v = {v};
-              else
-                v = v(:)';
-              endif
-              ## Recursively call assert for struct array values
-              assert (v, {expected.(k)}, tol);
-            endfor
+            assert (isempty (cond), isempty (expected));
+
+            if (! isempty (cond))
+              for [v, k] = cond
+                if (numel (cond) == 1)
+                  v = {v};
+                else
+                  v = v(:)';
+                endif
+                ## Recursively call assert for struct array values
+                assert (v, {expected.(k)}, tol);
+              endfor
+            endif
           catch
             err.index{end+1} = ".";
             err.observed{end+1} = "O";
@@ -624,7 +624,7 @@
 %! x.b = 1;
 %! y.a = 1;
 %! assert (x,y);
-%!error <'b' is not an expected field>
+%!error <Structure fieldname mismatch>
 %! x.b = 1;
 %! y.a = 1;
 %! assert (x,y);
--- a/test/nest/nest.tst	Wed Jul 01 15:33:53 2020 -0400
+++ b/test/nest/nest.tst	Thu Jul 02 15:11:19 2020 +0900
@@ -37,7 +37,11 @@
 
 %!assert (recursive_nest3 (), 5)
 
-%!assert (script_nest (), 5)
+## FIXME: The following test works in Matlab R2020b, but in Octave it never
+##        worked.  The output of "script_nest" is unassigned. This got
+##        revealed by fixing bug #58686.
+
+%!xtest assert (script_nest (), 5)
 
 %!assert (arg_ret (), 10)