Skip Menu |

This queue is for tickets about the Number-Fraction CPAN distribution.

Report information
The Basics
Id: 17923
Status: resolved
Priority: 0/
Queue: Number-Fraction

People
Owner: DAVECROSS [...] cpan.org
Requestors: davidrw [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.08
Fixed in: (no value)



Subject: [patch] fix ->new( <single integer argument> )
The POD for new() for Number-Fraction-1.08 says that it can take "A single integer which is used as the numerator of the the new object. The denominator is set to 1." but instead new() errors out and returns undef. Here's a patch that implements the described behavior. Also attached is a test script for it, but it needs the comparison operators from http://rt.cpan.org/Ticket/Display.html?id=17922 to be fully functional (the test script, that is -- the patch doesn't rely on the comparison operators in any way) --david
Subject: single_arg.txt
Download single_arg.txt
application/force-download 417b

Message body not shown because it is not plain text.

Subject: single_arg.t
#!/usr/bin/perl use strict; use warnings; use Test::More tests => 11; use Number::Fraction; foreach my $n ( qw( 1 2 -3 1/2 -1/2 ) ){ my $x = Number::Fraction->new($n); ok( $x == $n, "got '$n'" ); } foreach my $n ( undef, '', qw( 0.5 a 1a 0.5.1 ) ){ my $x = Number::Fraction->new($n); is( $x, undef, "got undef for '$n'" ); }
On Wed Mar 01 16:34:12 2006, DAVIDRW wrote: Show quoted text
> The POD for new() for Number-Fraction-1.08 says that it can take > "A single integer which is used as the numerator of the the new object. > The denominator is set to 1." but instead new() errors out and returns > undef. Here's a patch that implements the described behavior. > > Also attached is a test script for it, but it needs the comparison > operators from http://rt.cpan.org/Ticket/Display.html?id=17922 to be > fully functional (the test script, that is -- the patch doesn't rely on > the comparison operators in any way)
Thanks for spotting that. The fix will be in the next version (which will hit CPAN in the next couple of days). Dave...