From: Vincent Pit Date: Fri, 24 Dec 2010 17:01:18 +0000 (+0100) Subject: Fix, export and test cmp_ok() X-Git-Tag: v0.01~26 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;ds=sidebyside;h=c966261ac55fcb079dfc1bf42b1152b4bb71bd0b;hp=eb0bd56068ca67ea93f621ef38f59dec9bdbbcd8;p=perl%2Fmodules%2FTest-Leaner.git Fix, export and test cmp_ok() --- diff --git a/MANIFEST b/MANIFEST index c4a91c3..e5fbf16 100644 --- a/MANIFEST +++ b/MANIFEST @@ -17,3 +17,4 @@ t/19-comments.t t/80-threads.t t/20-ok.t t/21-is.t +t/22-cmp_ok.t diff --git a/lib/Test/Leaner.pm b/lib/Test/Leaner.pm index c4c577d..5e2f0a5 100644 --- a/lib/Test/Leaner.pm +++ b/lib/Test/Leaner.pm @@ -122,6 +122,7 @@ our @EXPORT = qw< ok is isnt + cmp_ok like unlike diag @@ -330,7 +331,7 @@ sub cmp_ok ($$$;$) { croak("Operator $op not supported") unless defined $name; @_ = ($x, $y, $desc); no strict 'refs'; - goto &{__PACKAGE__."is_$name"}; + goto &{__PACKAGE__."::is_$name"}; } sub _diag_fh { diff --git a/t/01-import.t b/t/01-import.t index 155dc43..d612ed4 100644 --- a/t/01-import.t +++ b/t/01-import.t @@ -7,7 +7,7 @@ use Test::More (); BEGIN { *tm_is = \&Test::More::is } -Test::More::plan(tests => 2 * 14); +Test::More::plan(tests => 2 * 15); require Test::Leaner; @@ -21,6 +21,7 @@ my @syms = qw< ok is isnt + cmp_ok like unlike diag diff --git a/t/22-cmp_ok.t b/t/22-cmp_ok.t new file mode 100644 index 0000000..f26d687 --- /dev/null +++ b/t/22-cmp_ok.t @@ -0,0 +1,25 @@ +#!perl -T + +use strict; +use warnings; + +use Test::Leaner tests => 4 * 8; + +my @num_tests = ( + [ '1.0', '==', '1.0' ], + [ '1e0', '==', '1e0' ], + [ '1.0', '<=', '1.0' ], + [ '1.0', '>=', '1.0' ], + [ '1.0', '<=', '2.0' ], + [ '1.0', '<', '2.0' ], + [ '2.0', '>=', '1.0' ], + [ '2.0', '>', '1.0' ], +); + +for my $t (@num_tests) { + my ($x, $op, $y) = @$t; + cmp_ok $x, $op, $y; + cmp_ok int($x), $op, $y; + cmp_ok $x, $op, int($y); + cmp_ok int($x), $op, int($y); +}