From: dpvc v. a. <we...@ma...> - 2005-11-17 13:23:46
|
Log Message: ----------- Give better error messages when the entries in Points, Vectors and Matrices are not of the right type. Modified Files: -------------- pg/lib/Parser/List: Matrix.pm Point.pm Vector.pm Revision Data ------------- Index: Vector.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Parser/List/Vector.pm,v retrieving revision 1.4 retrieving revision 1.5 diff -Llib/Parser/List/Vector.pm -Llib/Parser/List/Vector.pm -u -r1.4 -r1.5 --- lib/Parser/List/Vector.pm +++ lib/Parser/List/Vector.pm @@ -16,8 +16,11 @@ sub _check { my $self = shift; foreach my $x (@{$self->{coords}}) { - $self->{equation}->Error("Coordinates of Vector must be Numbers") - unless $x->isNumber; + unless ($x->isNumber) { + my $type = $x->type; + $type = (($type =~ m/^[aeiou]/i)? "an ": "a ") . $type; + $self->{equation}->Error(["Coordinates of Vectors must be Numbers, not %s",$type]); + } } } Index: Matrix.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Parser/List/Matrix.pm,v retrieving revision 1.4 retrieving revision 1.5 diff -Llib/Parser/List/Matrix.pm -Llib/Parser/List/Matrix.pm -u -r1.4 -r1.5 --- lib/Parser/List/Matrix.pm +++ lib/Parser/List/Matrix.pm @@ -19,6 +19,10 @@ foreach my $x (@{$self->{coords}}) {$x->makeMatrix($self->{type}{name},$self->{open},$self->{close})} } + foreach my $x (@{$self->{coords}}) { + $self->{equation}->Error("Entries in a Matrix must be Numbers or Lists") + unless ($x->class =~ m/Number|List/); + } } # Index: Point.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Parser/List/Point.pm,v retrieving revision 1.2 retrieving revision 1.3 diff -Llib/Parser/List/Point.pm -Llib/Parser/List/Point.pm -u -r1.2 -r1.3 --- lib/Parser/List/Point.pm +++ lib/Parser/List/Point.pm @@ -7,10 +7,20 @@ @ISA = qw(Parser::List); # -# The basic List class does it all. We only need this class -# for its name. +# The basic List class does most of the checking. # +sub _check { + my $self = shift; + foreach my $x (@{$self->{coords}}) { + unless ($x->isNumber) { + my $type = $x->type; + $type = (($type =~ m/^[aeiou]/i)? "an ": "a ") . $type; + $self->{equation}->Error(["Coordinates of Points must be Numbers, not %s",$type]); + } + } +} + ######################################################################### 1; |