]> git.vpit.fr Git - perl/modules/Test-Leaner.git/blobdiff - lib/Test/Leaner.pm
Only is() should treat undef specially
[perl/modules/Test-Leaner.git] / lib / Test / Leaner.pm
index c4c577d2dde61f0eeece12b0f6ccdf9c6ff1a721..a022c92bedc56565fc3b671e60705b995b3878ab 100644 (file)
@@ -122,6 +122,7 @@ our @EXPORT = qw<
  ok
  is
  isnt
+ cmp_ok
  like
  unlike
  diag
@@ -295,11 +296,7 @@ BEGIN {
   eval <<"IS_BINOP";
 sub is_$name (\$\$;\$) {
  my (\$x, \$y, \$desc) = \@_;
- no warnings 'uninitialized';
- \@_ = (
-  (not(defined \$x xor defined \$y) and \$x $op \$y),
-  \$desc,
- );
+ \@_ = ((\$x $op \$y), \$desc);
  goto &ok;
 }
 IS_BINOP
@@ -307,11 +304,14 @@ IS_BINOP
  }
 }
 
-{
- no warnings 'once';
- *is     = \&is_eq;
- *like   = \&is_like;
- *unlike = \&is_unlike;
+sub is ($$;$) {
+ my ($got, $expected, $desc) = @_;
+ no warnings 'uninitialized';
+ @_ = (
+  (not(defined $got xor defined $expected) and $got eq $expected),
+  $desc,
+ );
+ goto &ok;
 }
 
 sub isnt ($$;$) {
@@ -324,13 +324,19 @@ sub isnt ($$;$) {
  goto &ok;
 }
 
+{
+ no warnings 'once';
+ *like   = \&is_like;
+ *unlike = \&is_unlike;
+}
+
 sub cmp_ok ($$$;$) {
  my ($x, $op, $y, $desc) = @_;
  my $name = $binops{$op};
  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 {