From: dpvc v. a. <we...@ma...> - 2009-03-10 14:19:23
|
Log Message: ----------- Fix the context::Fraction::Real object so that new() and make() will handle being passed a fraction as a string (since Value::makeValue() will pass that to context::Fraction::Real->make() when it is given a fraction as a string). Modified Files: -------------- pg/macros: contextFraction.pl Revision Data ------------- Index: contextFraction.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/contextFraction.pl,v retrieving revision 1.3 retrieving revision 1.4 diff -Lmacros/contextFraction.pl -Lmacros/contextFraction.pl -u -r1.3 -r1.4 --- macros/contextFraction.pl +++ macros/contextFraction.pl @@ -499,12 +499,25 @@ # Allow Real to convert Fractions to Reals # sub new { - my $self = shift; my $class = ref($self) || $self; - my $context = (Value::isContext($_[0]) ? shift : $self->context); - my $x = shift; $x = $x->eval if scalar(@_) == 0 && Value::classMatch($x,'Fraction'); + my $self = shift; my $context = (Value::isContext($_[0]) ? shift : $self->context); + my $x = shift; + $x = $context->Package("Formula")->new($context,$x)->eval if ref($x) eq "" && $x =~ m!/!; + $x = $x->eval if scalar(@_) == 0 && Value::classMatch($x,'Fraction'); $self->SUPER::new($context,$x,@_); } +# +# Since the signed number pattern now include fractions, we need to make sure +# we handle them when a real is made and it looks like a fraction +# +sub make { + my $self = shift; my $context = (Value::isContext($_[0]) ? shift : $self->context); + my $x = shift; + $x = $context->Package("Formula")->new($context,$x)->eval if ref($x) eq "" && $x =~ m!/!; + $x = $x->eval if scalar(@_) == 0 && Value::classMatch($x,'Fraction'); + $self->SUPER::make($context,$x,@_); +} + ########################################################################### ########################################################################### # |