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 |
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'" );
}