# HG changeset patch
# User Julien Bect <julien.bect@supelec.fr>
# Date 1359478553 -3600
# Node ID 44f5f3322c2c9652533ad2cb12a06819f6300386
# Parent  9194bb707d63e904596a5a24b4c35f601102e45e
Modify pt-mat.cc to solve a problem related to vertcat/horzcat overloading.

* pt-mat.cc (tm_row_const::tm_row_const_rep::init): Do not check dimension
  consistency when at least one of the elements is an object (this was
  preventing horzcat overloading from working properly, see bug #38128).
  (tm_const::init): Same thing for vertical concatenation (this was
  preventing vertcat overloading from working properly, see bug #38128).

* test/classes/classes.tst: Add tests for the vertical and horizontal
  concatenation of objects when neither vertcat() nor horzcat() is
  overloaded.

diff -r 9194bb707d63 -r 44f5f3322c2c libinterp/parse-tree/pt-mat.cc
--- a/libinterp/parse-tree/pt-mat.cc	jeu. févr. 07 17:21:10 2013 -0800
+++ b/libinterp/parse-tree/pt-mat.cc	mar. janv. 29 17:55:53 2013 +0100
@@ -402,7 +402,7 @@
               first_elem = false;
               dv = this_elt_dv;
             }
-          else if (! dv.hvcat (this_elt_dv, 1))
+          else if ((! any_class) && (! dv.hvcat (this_elt_dv, 1)))
             {
               eval_error ("horizontal dimensions mismatch", dv, this_elt_dv);
               break;
@@ -644,7 +644,7 @@
                 dv(1) = this_elt_nc;
               dv(0) += this_elt_nr;
             }
-          else if (! dv.hvcat (this_elt_dv, 0))
+          else if ((!any_class) && (!dv.hvcat (this_elt_dv, 0)))
             {
               eval_error ("vertical dimensions mismatch", dv, this_elt_dv);
               return;
diff -r 9194bb707d63 -r 44f5f3322c2c test/classes/classes.tst
--- a/test/classes/classes.tst	jeu. févr. 07 17:21:10 2013 -0800
+++ b/test/classes/classes.tst	mar. janv. 29 17:55:53 2013 +0100
@@ -304,6 +304,10 @@
 %!assert (s1 >= (x1 - 1))
 %!assert (x1 >= (s1 - 1))
 
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% Testing horizontal & vertical concatenation %%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
 %% Test overloaded vertcat() for the Snork class
 %% See bug #38170 (http://savannah.gnu.org/bugs/?38170)
 %!test   s = [s1; s2];  assert (isa (s, 'Snork') && isequal (s.gick, [x1; x2]));
@@ -316,3 +320,16 @@
 %!xtest  s = [s1 x2];  assert (isa (s, 'Snork') && isequal (s.gick, [x1 x2]));
 %!xtest  s = [x1 s2];  assert (isa (s, 'Snork') && isequal (s.gick, [x1 x2]));
 
+%% Test with the Blork class, where neither vertcat() nor horzcat() is overloaded
+%!shared x1, x2, x3
+%!test x1 = Blork();
+%!test x2 = [x1 x1];
+%!assert (isa (x2, 'Blork') && isequal (size (x2), [1 2]));
+%!test x2 = [x1 51];
+%!assert (isa (x2, 'Blork') && isequal (size (x2), [1 2]));
+%!test x3 = [x2; x2];
+%!assert (isa (x3, 'Blork') && isequal (size (x3), [2 2]));
+%!test x3 = [x2; [51 x1]];
+%!assert (isa (x3, 'Blork') && isequal (size (x3), [2 2]));
+%!error <dimension mismatch> x4 = [x1  x3];
+%!error <dimension mismatch> x4 = [x1; x3];
