Mercurial > jwe > octave
changeset 20795:ba2367658dc8
Use ':' rather than ';' in error messages from bad indexing (bug #46536).
* lo-array-gripes.cc (gripe_del_index_out_of_range): Change ';' to ':' after
"index out of bounds".
* sub2ind.cc (Fsub2ind): Update BIST tests to use ':' when checking.
* index.tst: Update BIST tests to use ':' when checking.
author | Rik <rik@octave.org> |
---|---|
date | Fri, 04 Dec 2015 10:03:38 -0800 |
parents | e870a68742a6 |
children | ed770c16a3e8 492738d32c60 |
files | libinterp/corefcn/sub2ind.cc liboctave/util/lo-array-gripes.cc test/index.tst |
diffstat | 3 files changed, 48 insertions(+), 48 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/sub2ind.cc Fri Dec 04 06:43:45 2015 +0100 +++ b/libinterp/corefcn/sub2ind.cc Fri Dec 04 10:03:38 2015 -0800 @@ -139,17 +139,17 @@ # Test high index %!assert (sub2ind ([10 10 10], 10, 10, 10), 1000) -%!error <index \(11,_,_\); out of bound 10> sub2ind ([10 10 10], 11, 10, 10) -%!error <index \(_,11,_\); out of bound 10> sub2ind ([10 10 10], 10, 11, 10) -%!error <index \(_,_,11\); out of bound 10> sub2ind ([10 10 10], 10, 10, 11) +%!error <index \(11,_,_\): out of bound 10> sub2ind ([10 10 10], 11, 10, 10) +%!error <index \(_,11,_\): out of bound 10> sub2ind ([10 10 10], 10, 11, 10) +%!error <index \(_,_,11\): out of bound 10> sub2ind ([10 10 10], 10, 10, 11) # Test high index in the trailing dimensions %!assert (sub2ind ([10, 1], 2, 1, 1), 2) -%!error <index \(_,2,_\); out of bound 1> sub2ind ([10, 1], 1, 2, 1) -%!error <index \(_,_,2\); out of bound 1> sub2ind ([10, 1], 1, 1, 2) +%!error <index \(_,2,_\): out of bound 1> sub2ind ([10, 1], 1, 2, 1) +%!error <index \(_,_,2\): out of bound 1> sub2ind ([10, 1], 1, 1, 2) %!assert (sub2ind ([10 10], 2, 2, 1), 12) -%!error <index \(_,_,2\); out of bound 1> sub2ind ([10 10], 2, 1, 2) -%!error <index \(_,_,2\); out of bound 1> sub2ind ([10 10], 1, 2, 2) +%!error <index \(_,_,2\): out of bound 1> sub2ind ([10 10], 2, 1, 2) +%!error <index \(_,_,2\): out of bound 1> sub2ind ([10 10], 1, 2, 2) # Test handling of empty arguments %!assert (sub2ind ([10 10], zeros (0,0), zeros (0,0)), zeros (0,0))
--- a/liboctave/util/lo-array-gripes.cc Fri Dec 04 06:43:45 2015 +0100 +++ b/liboctave/util/lo-array-gripes.cc Fri Dec 04 10:03:38 2015 -0800 @@ -98,7 +98,7 @@ const char *err_id = error_id_index_out_of_bounds; (*current_liboctave_error_with_id_handler) - (err_id, "A(%s) = []: index out of bounds; value %d out of bound %d", + (err_id, "A(%s) = []: index out of bounds: value %d out of bound %d", is1d ? "I" : "..,I,..", idx, ext); } @@ -111,7 +111,7 @@ std::string index_exception::message (void) const { - std::string msg = expression () + "; " + details (); + std::string msg = expression () + ": " + details (); return msg.c_str (); }
--- a/test/index.tst Fri Dec 04 06:43:45 2015 +0100 +++ b/test/index.tst Fri Dec 04 10:03:38 2015 -0800 @@ -498,81 +498,81 @@ ## Test indexing of unnamed constants -%!error <index \(0\); subscripts must be> 1(0) -%!error <index \(-1\); subscripts must be> 1(-1) -%!error <index \(_,0.5\); subscripts> {}(1,0.5) -%!error <index \(nan,_\); subscripts> 1(NaN,1) -%!error <index \(_,_,<cell....\[x8\]...\); subscripts> [](1,1,{},1,1,1,1,1,1,1,1) -%!error <index \(...\[x9\]...-1,_\); subscript> 1(1,1,1,1,1,1,1,1,1,-1,1) -%!error <index \(2\); out of bound 1> 1(2) -%!error <index \(1\); out of bound 0> [](1) -%!error <index \(_,1\); but object has size 5x0> zeros(5,0)(3,1) -%!error <index \(3,_\); but object has size 0x5> zeros(0,5)(3,1) -%!error <index \(-1\); subscripts> 1(1)(-1)(1) +%!error <index \(0\): subscripts must be> 1(0) +%!error <index \(-1\): subscripts must be> 1(-1) +%!error <index \(_,0.5\): subscripts> {}(1,0.5) +%!error <index \(nan,_\): subscripts> 1(NaN,1) +%!error <index \(_,_,<cell....\[x8\]...\): subscripts> [](1,1,{},1,1,1,1,1,1,1,1) +%!error <index \(...\[x9\]...-1,_\): subscript> 1(1,1,1,1,1,1,1,1,1,-1,1) +%!error <index \(2\): out of bound 1> 1(2) +%!error <index \(1\): out of bound 0> [](1) +%!error <index \(_,1\): but object has size 5x0> zeros(5,0)(3,1) +%!error <index \(3,_\): but object has size 0x5> zeros(0,5)(3,1) +%!error <index \(-1\): subscripts> 1(1)(-1)(1) %! %!shared abc %! abc = [1, 2]; %! ## Test full matrices in variables -%!error <abc\(3\); out of bound 2> abc([false, true, true]) -%!error <abc\(-1\); subscripts> abc(-1)(1)(1) -%! ## xerror <index \(-1\); subscripts> abc(1)(-1)(1) ## why no 'xerror' test? +%!error <abc\(3\): out of bound 2> abc([false, true, true]) +%!error <abc\(-1\): subscripts> abc(-1)(1)(1) +%! ## xerror <index \(-1\): subscripts> abc(1)(-1)(1) ## why no 'xerror' test? %!shared abc %! abc = [1 2; 3 4]; -%!error <abc\(5\); out of bound 4> abc(5) -%!error <abc\(_,3\); but abc has size 2x2> abc(2,3) -%!error <abc\(_,_,0.5\); subscripts> exp (abc(2,3,0.5)) +%!error <abc\(5\): out of bound 4> abc(5) +%!error <abc\(_,3\): but abc has size 2x2> abc(2,3) +%!error <abc\(_,_,0.5\): subscripts> exp (abc(2,3,0.5)) %!shared abc %! abc = [1 2; 3 4]; abc(1,1,2) = 1; -%!error <abc\(_,5\); out of bound 4> abc(2,5) -%!error <abc\(_,3,_\); but abc has size 2x2x2> abc(2,3,2) +%!error <abc\(_,5\): out of bound 4> abc(2,5) +%!error <abc\(_,3,_\): but abc has size 2x2x2> abc(2,3,2) %!error <A\(..,I,..\) = \[\]: .* value 3 out of bound 2> abc(3,:) = [] %!error <A\(I\) = \[\]: .* value 50 out of bound 8> abc(3:50) = [] %!error <a null assignment can only have one non-colon index> abc(3,5) = [] %!error <=: nonconformant arguments \(op1 is 1x1, op2 is 1x5\)> abc(3,5) = 1:5 %! ## Test diagonal matrices, and access of function results -%!error <index \(_,_,5\); but object has size 3x3> eye(3)(2,3,5) -%!error <index \(-2,_\); subscripts> eye(4)(-2,3) +%!error <index \(_,_,5\): but object has size 3x3> eye(3)(2,3,5) +%!error <index \(-2,_\): subscripts> eye(4)(-2,3) %! ## Test cells %!shared abc %! abc = {1, 2; 3, 4}; -%!error <abc\(_,0.3,_\); subscripts> abc(2,0.3,5) -%!error <abc\(_,0.3,_\); subscripts> abc{2,0.3,5} -%!error <abc\(-2,_,_,_\); subscripts> abc{-2,1,1,1} -%!error <abc\(0,_,_,_\); subscripts> abc(0,1,1,1) = 1 +%!error <abc\(_,0.3,_\): subscripts> abc(2,0.3,5) +%!error <abc\(_,0.3,_\): subscripts> abc{2,0.3,5} +%!error <abc\(-2,_,_,_\): subscripts> abc{-2,1,1,1} +%!error <abc\(0,_,_,_\): subscripts> abc(0,1,1,1) = 1 %! ## Test permutation matrices %!shared abc %! abc = eye(3)([3 1 2],:); -%!error <abc\(nan\); subscripts> abc(NA) -%!error <abc\(_,_,_,inf,_\); subscripts> abc(1,1,1,Inf,1) +%!error <abc\(nan\): subscripts> abc(NA) +%!error <abc\(_,_,_,inf,_\): subscripts> abc(1,1,1,Inf,1) %! ## Test sparse matrices %!shared abc %! abc = sparse(3,3); -%!error <abc\(-1\); subscripts> abc(-1) -%!error <abc\(-1\); subscripts> abc(-1) = 1 -%!error <abc\(-1,_\); subscripts> abc(-1,1) -%!error <abc\(-1,_\); subscripts> abc(-1,1) = 1 +%!error <abc\(-1\): subscripts> abc(-1) +%!error <abc\(-1\): subscripts> abc(-1) = 1 +%!error <abc\(-1,_\): subscripts> abc(-1,1) +%!error <abc\(-1,_\): subscripts> abc(-1,1) = 1 %!error <sparse indexing needs 1 or 2 indices> abc(0,0,0,0) -%!error <abc\(4,_\); but abc has size 3x3> abc(4,1) +%!error <abc\(4,_\): but abc has size 3x3> abc(4,1) %! ## Test ranges %!shared abc %! abc = 1:10; -%!error <abc\(-1\); subscripts> abc(-1) -%!error <abc\(-1,_\); subscripts> abc(-1,1) -%!error <abc\(4,_\); but abc has size 1x10> abc(4,1) +%!error <abc\(-1\): subscripts> abc(-1) +%!error <abc\(-1,_\): subscripts> abc(-1,1) +%!error <abc\(4,_\): but abc has size 1x10> abc(4,1) %! ## Test complex %!shared abc, z %! abc = [1 2]; -%!error <abc\(0\+1i\); subscripts must be real> abc(i) +%!error <abc\(0\+1i\): subscripts must be real> abc(i) %! abc = [1 2; 3 4]; -%!error <abc\(1\+0i\); subscripts must be real> abc(complex(1)) -%!error <abc\(1\+0.5i,_\); subscripts must be real> abc(1+0.5*i,3) -%!error <abc\(_,0-2i\); subscripts must be real> abc(2,0-2*i) +%!error <abc\(1\+0i\): subscripts must be real> abc(complex(1)) +%!error <abc\(1\+0.5i,_\): subscripts must be real> abc(1+0.5*i,3) +%!error <abc\(_,0-2i\): subscripts must be real> abc(2,0-2*i)