require strict; import strict;
}
-use Test;
-
-BEGIN { plan tests => 12 }
+use Test::More tests => 12;
use IO::File;
my $io = IO::File->new($File) or die $!;
<F> for (1 .. 10);
-ok(lineno($io), "10 0 10");
+is(lineno($io), "10 0 10");
$io->getline for (1 .. 5);
-ok(lineno($io), "5 5 5");
+is(lineno($io), "5 5 5");
<F>;
-ok(lineno($io), "11 5 11");
+is(lineno($io), "11 5 11");
$io->getline;
-ok(lineno($io), "6 6 6");
+is(lineno($io), "6 6 6");
$t = tell F; # tell F; provokes a warning
-ok(lineno($io), "11 6 11");
+is(lineno($io), "11 6 11");
<F>;
-ok(lineno($io), "12 6 12");
+is(lineno($io), "12 6 12");
select F;
-ok(lineno($io), "12 6 12");
+is(lineno($io), "12 6 12");
<F> for (1 .. 10);
-ok(lineno($io), "22 6 22");
+is(lineno($io), "22 6 22");
$io->getline for (1 .. 5);
-ok(lineno($io), "11 11 11");
+is(lineno($io), "11 11 11");
$t = tell F;
# We used to have problems here before local $. worked.
# input_line_number() used to use select and tell. When we did the
-# same, that mechanism broke. It should work now.
-ok(lineno($io), "22 11 22");
+# same, that mechanism brise. It should work now.
+is(lineno($io), "22 11 22");
{
local $.;
$io->getline for (1 .. 5);
- ok(lineno($io), "16 16 16");
+ is(lineno($io), "16 16 16");
}
-ok(lineno($io), "22 16 22");
+is(lineno($io), "22 16 22");
Examples for rounding:
use Math::BigFloat;
- use Test;
+ use Test::More;
$x = Math::BigFloat->new(123.4567);
$y = Math::BigFloat->new(123.456789);
Math::BigFloat->accuracy(4); # no more A than 4
- ok ($x->copy()->fround(),123.4); # even rounding
+ is ($x->copy()->fround(),123.4); # even rounding
print $x->copy()->fround(),"\n"; # 123.4
Math::BigFloat->round_mode('odd'); # round to odd
print $x->copy()->fround(),"\n"; # 123.5
Both C<bstr()> and C<bsstr()> as well as automated stringify via overload now
drop the leading '+'. The old code would return '+3', the new returns '3'.
This is to be consistent with Perl and to make C<cmp> (especially with
-overloading) to work as you expect. It also solves problems with C<Test.pm>,
-because its C<ok()> uses 'eq' internally.
+overloading) to work as you expect. It also solves problems with C<Test.pm>
+and L<Test::More>, which stringify arguments before comparing them.
Mark Biggar said, when asked about to drop the '+' altogether, or make only
C<cmp> work:
So, the following examples will now work all as expected:
- use Test;
- BEGIN { plan tests => 1 }
+ use Test::More tests => 1;
use Math::BigInt;
my $x = new Math::BigInt 3*3;
my $y = new Math::BigInt 3*3;
- ok ($x,3*3);
+ is ($x,3*3, 'multiplication');
print "$x eq 9" if $x eq $y;
print "$x eq 9" if $x eq '9';
print "$x eq 9" if $x eq 3*3;
as 1e+308. If in doubt, convert both arguments to Math::BigInt before
comparing them as strings:
- use Test;
- BEGIN { plan tests => 3 }
+ use Test::More tests => 3;
use Math::BigInt;
$x = Math::BigInt->new('1e56'); $y = 1e56;
- ok ($x,$y); # will fail
- ok ($x->bsstr(),$y); # okay
+ is ($x,$y); # will fail
+ is ($x->bsstr(),$y); # okay
$y = Math::BigInt->new($y);
- ok ($x,$y); # okay
+ is ($x,$y); # okay
Alternatively, simply use C<< <=> >> for comparisons, this will get it
always right. There is not yet a way to get a number automatically represented