C<use_ok>, C<require_ok>, C<can_ok>, C<isa_ok>, C<new_ok>, C<subtest>, C<explain>, C<TODO> blocks and C<todo_skip> are not implemented.
-=item *
-
-L<Test::Leaner> depends on L<Scalar::Util>, while L<Test::More> does not.
-
=back
=cut
-use Exporter ();
-use Scalar::Util ();
+use Exporter ();
BEGIN {
if ($] >= 5.008 and $INC{'threads.pm'}) {
=cut
+BEGIN {
+ local $@;
+ if (eval { require Scalar::Util; 1 }) {
+ *_reftype = \&Scalar::Util::reftype;
+ } else {
+ # Stolen from Scalar::Util::PP
+ require B;
+ my %tmap = qw<
+ B::NULL SCALAR
+
+ B::HV HASH
+ B::AV ARRAY
+ B::CV CODE
+ B::IO IO
+ B::GV GLOB
+ B::REGEXP REGEXP
+ >;
+ *_reftype = sub ($) {
+ my $r = shift;
+
+ return undef unless length ref $r;
+
+ my $t = ref B::svref_2object($r);
+
+ return exists $tmap{$t} ? $tmap{$t}
+ : length ref $$r ? 'REF'
+ : 'SCALAR'
+ }
+ }
+}
+
sub _deep_ref_check {
my ($x, $y, $ry) = @_;
next if not(ref $ex xor ref $ey) and $ex eq $ey;
- $ry = Scalar::Util::reftype($ey);
- return 0 if Scalar::Util::reftype($ex) ne $ry;
+ $ry = _reftype($ey);
+ return 0 if _reftype($ex) ne $ry;
return 0 unless $ry and _deep_ref_check($ex, $ey, $ry);
}
next if not(ref $ex xor ref $ey) and $ex eq $ey;
- $ry = Scalar::Util::reftype($ey);
- return 0 if Scalar::Util::reftype($ex) ne $ry;
+ $ry = _reftype($ey);
+ return 0 if _reftype($ex) ne $ry;
return 0 unless $ry and _deep_ref_check($ex, $ey, $ry);
}
# Test::More::is_deeply happily breaks encapsulation if the objects aren't
# overloaded.
- my $ry = Scalar::Util::reftype($y);
- return 0 if Scalar::Util::reftype($x) ne $ry;
+ my $ry = _reftype($y);
+ return 0 if _reftype($x) ne $ry;
# Shortcut if $x and $y are both not references and failed the previous
# $x eq $y test.
L<perl> 5.6.
-L<Exporter>, L<Scalar::Util>, L<Test::More>.
+L<Exporter>, L<Test::More>.
=head1 AUTHOR