File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1502,6 +1502,7 @@ sub removeRow {
15021502 my @dim = $self -> dimensions;
15031503 my $degree = scalar @dim ;
15041504 Value::Error(" removeRow cannot be used on a Matrix of degree 1" ) if $degree == 1;
1505+ Value::Error(" cannot remove a Matrix's only row" ) if $dim [0] == 1;
15051506 my @indices = map { [ 1 .. $_ ] } @dim ;
15061507 Value::Error(" Can only remove rows 1 through $indices [0][-1]" )
15071508 unless $r =~ / ^\d +$ / && $r >= 1 && $r <= $indices [0][-1];
@@ -1529,6 +1530,7 @@ sub removeColumn {
15291530 my @dim = $self -> dimensions;
15301531 my $degree = scalar @dim ;
15311532 Value::Error(" removeColumn cannot be used on a Matrix of degree 1" ) if $degree == 1;
1533+ Value::Error(" cannot remove a Matrix's only column" ) if $dim [1] == 1;
15321534 my @indices = map { [ 1 .. $_ ] } @dim ;
15331535 Value::Error(" Can only remove columns 1 through $indices [1][-1]" )
15341536 unless $r =~ / ^\d +$ / && $r >= 1 && $r <= $indices [1][-1];
Original file line number Diff line number Diff line change @@ -334,6 +334,11 @@ subtest 'Remove row' => sub {
334334 like dies {
335335 $A -> removeRow(' a' );
336336 }, qr / Can only remove rows 1 through 4/ , ' check that error is thrown for bad row specification' ;
337+
338+ my $D = Matrix([ [ 1, 2, 3 ] ]);
339+ like dies {
340+ $D -> removeRow(1);
341+ }, qr / cannot remove a Matrix's only row/ , ' check that error is thrown for trying to remove the only row' ;
337342};
338343
339344subtest ' Remove column' => sub {
@@ -362,6 +367,11 @@ subtest 'Remove column' => sub {
362367 like dies {
363368 $A -> removeColumn(' a' );
364369 }, qr / Can only remove columns 1 through 4/ , ' check that error is thrown for bad column specification' ;
370+
371+ my $D = Matrix([1], [2], [3]);
372+ like dies {
373+ $D -> removeColumn(1);
374+ }, qr / cannot remove a Matrix's only column/ , ' check that error is thrown for trying to remove the only column' ;
365375};
366376
367377subtest ' Construct an identity matrix' => sub {
You can’t perform that action at this time.
0 commit comments