From 8c46a73fab092ade7e3c47e0fe0e503d9352eb2b Mon Sep 17 00:00:00 2001 From: "Nicholas R. Jankowski" Date: Wed, 8 Jan 2025 09:59:28 -0500 Subject: [PATCH] add arrayfun BIST for function failing to return requested output (bug #66642) * cellfun.cc (arrayfun): Add BIST testing for error message to be produced when called function does not return values for requested outputs. * cellfun.cc (cellfun): Add explanatory comment for previously added BIST. --- libinterp/corefcn/cellfun.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libinterp/corefcn/cellfun.cc b/libinterp/corefcn/cellfun.cc index 1458b99186..fd3a20fefe 100644 --- a/libinterp/corefcn/cellfun.cc +++ b/libinterp/corefcn/cellfun.cc @@ -1045,6 +1045,7 @@ v = cellfun (@@det, C); # 40% faster %! assert (! isempty (__errmsg)); %! clear -global __errmsg; +## An error should occur if called function does not return requested outputs %!function [a, b] = __counterror (x) %! a = x; %!endfunction @@ -1674,6 +1675,13 @@ arrayfun (@@str2num, [1234], %! assert ([(isempty (A(1).message)), (isempty (A(2).message))], %! [false, false]); %! assert ([A(1).index, A(2).index], [1, 2]); + +## An error should occur if called function does not return requested outputs +%!function [a, b] = __counterror (x) +%! a = x; +%!endfunction +%!test <66642> +%! fail ("[a, b] = arrayfun (@__counterror, [1, 4])"); */ static void