Commits

Shlomi Fish committed 731ea03

Implement the eq_or_diff that does not require Test::Differences.

It defaults on is_deeply.

Comments (0)

Files changed (3)

t/28new_callbacks_multiple.t

 use strict;
 use warnings;
 
+use lib './t/lib';
+
 package Collector;
 
 sub new
 
 package Stacker;
 
+use TestHelpers;
+
 our @ISA = qw(Collector);
 
 sub _stack
 
     local $Test::Builder::Level = $Test::Builder::Level + 1;
 
-    Test::More::is_deeply ($self->_stack(), $value, $blurb);
+    eq_or_diff ($self->_stack(), $value, $blurb);
 
     $self->_reset;
 
     my $dom = $parser->load_html(string => $content);
 
     # TEST
-    is_deeply(
+    eq_or_diff(
         \@warnings,
         [],
         'suppress_errors worked.',

t/lib/TestHelpers.pm

 use strict;
 use warnings;
 
-our @EXPORT = (qw(slurp utf8_slurp));
+our @EXPORT = (qw(slurp utf8_slurp eq_or_diff));
 
 use base 'Exporter';
 
+use Test::More ();
+
 sub slurp
 {
     my $filename = shift;
     return $contents;
 }
 
+my $_eq_or_diff_ref;
+
+if (eval "require Test::Differences; 1;" && (!$@))
+{
+    $_eq_or_diff_ref = \&Test::Differences::eq_or_diff;
+}
+else
+{
+    $_eq_or_diff_ref = \&Test::More::is_deeply;
+}
+
+sub eq_or_diff
+{
+    local $Test::Builder::Level = $Test::Builder::Level + 1;
+
+    return $_eq_or_diff_ref->(@_);
+}
 
 1;