The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
Changes 09
META.json 225
META.yml 415
lib/Test/Most/Exception.pm 1313
lib/Test/Most.pm 275300
t/defer_plan.t 01
6 files changed (This is a version diff) 294363
@@ -1,5 +1,14 @@
 Revision history for Test::Most
 
+0.34    2014-08-03
+        - Make compatible with the new Test::Builder (exodist - Chad Granum)
+        - Backwards-incompatible change: reftype no longer exported by
+          default. See https://github.com/Ovid/test--most/issues/6 (reported
+          by rjattril). This should not be noticed by most users
+          (crosses-fingers).
+        - defer_plan() has long been deprecated and will be removed in a
+          future release. This release carp()s if you try to call it.
+
 0.33    2013-01-12
         - Oops. Uploaded a bad .tar.gz
 
@@ -4,7 +4,7 @@
       "unknown"
    ],
    "dynamic_config" : 1,
-   "generated_by" : "ExtUtils::MakeMaker version 6.66, CPAN::Meta::Converter version 2.132830",
+   "generated_by" : "ExtUtils::MakeMaker version 6.92, CPAN::Meta::Converter version 2.140640",
    "license" : [
       "unknown"
    ],
@@ -19,6 +19,29 @@
          "inc"
       ]
    },
+   "prereqs" : {
+      "build" : {
+         "requires" : {
+            "ExtUtils::MakeMaker" : "0"
+         }
+      },
+      "configure" : {
+         "requires" : {
+            "ExtUtils::MakeMaker" : "0"
+         }
+      },
+      "runtime" : {
+         "requires" : {
+            "Exception::Class" : "1.14",
+            "Test::Deep" : "0.106",
+            "Test::Differences" : "0.61",
+            "Test::Exception" : "0.31",
+            "Test::Harness" : "3.21",
+            "Test::More" : "0.88",
+            "Test::Warn" : "0.23"
+         }
+      }
+   },
    "release_status" : "stable",
    "resources" : {
       "repository" : {
@@ -26,5 +49,5 @@
          "web" : "https://github.com/Ovid/test--most"
       }
    },
-   "version" : "0.33"
+   "version" : "0.34"
 }
@@ -2,18 +2,29 @@
 abstract: unknown
 author:
   - unknown
-build_requires: {}
+build_requires:
+  ExtUtils::MakeMaker: '0'
+configure_requires:
+  ExtUtils::MakeMaker: '0'
 dynamic_config: 1
-generated_by: 'ExtUtils::MakeMaker version 6.66, CPAN::Meta::Converter version 2.132830'
+generated_by: 'ExtUtils::MakeMaker version 6.92, CPAN::Meta::Converter version 2.140640'
 license: unknown
 meta-spec:
   url: http://module-build.sourceforge.net/META-spec-v1.4.html
-  version: 1.4
+  version: '1.4'
 name: Test-Most
 no_index:
   directory:
     - t
     - inc
+requires:
+  Exception::Class: '1.14'
+  Test::Deep: '0.106'
+  Test::Differences: '0.61'
+  Test::Exception: '0.31'
+  Test::Harness: '3.21'
+  Test::More: '0.88'
+  Test::Warn: '0.23'
 resources:
   repository: https://github.com/Ovid/test--most
-version: 0.33
+version: '0.34'
@@ -6,18 +6,25 @@ use strict;
 use base 'Exporter';
 our @EXPORT_OK = ('throw_failure');
 
+our $VERSION = '0.34';
+$VERSION = eval $VERSION;
+
+use Exception::Class 'Test::Most::Exception' => {
+    alias       => 'throw_failure',
+    description => 'Test failed.  Stopping test.',
+};
+
+1;
+
+__END__
+
 =head1 NAME
 
 Test::Most::Exception - Internal exception class
 
 =head1 VERSION
 
-Version 0.33
-
-=cut
-
-our $VERSION = '0.33';
-$VERSION = eval $VERSION;
+Version 0.34
 
 =head1 SYNOPSIS
 
@@ -33,13 +40,6 @@ This is the exception for C<die_on_fail>.
 
 =cut
 
-use Exception::Class 'Test::Most::Exception' => {
-    alias       => 'throw_failure',
-    description => 'Test failed.  Stopping test.',
-};
-
-1;
-
 =head1 AUTHOR
 
 Curtis Poe, C<< <ovid at cpan.org> >>
@@ -12,11 +12,17 @@ my $HAVE_TIME_HIRES;
 
 BEGIN {
 
-    # There's some strange fiddling around with import(), so this allows us to
-    # be nicely backwards compatible to earlier versions of Test::More.
     require Test::More;
-    @Test::More::EXPORT = grep { $_ ne 'explain' } @Test::More::EXPORT;
-    Test::More->import;
+    if (Test::More->can('TB_PROVIDER_META')) {
+        Test::More->import(import => [ '!explain' ]);
+    }
+    else {
+        # There's some strange fiddling around with import(), so this allows us to
+        # be nicely backwards compatible to earlier versions of Test::More.
+        @Test::More::EXPORT = grep { $_ ne 'explain' } @Test::More::EXPORT;
+        Test::More->import;
+    }
+
     eval "use Time::HiRes";
     $HAVE_TIME_HIRES = 1 unless $@;
 }
@@ -27,18 +33,291 @@ BEGIN {
     $OK_FUNC = \&Test::Builder::ok;
 }
 
-=head1 NAME
+our $VERSION = '0.34';
+$VERSION = eval $VERSION;
 
-Test::Most - Most commonly needed test functions and features.
+BEGIN {
+    @ISA    = qw(Test::Builder::Module);
+    @EXPORT = (
+        Test::More->can('TB_PROVIDER_META')
+            ? grep { $_ ne 'TODO' } keys( %{Test::More->TB_PROVIDER_META->{attrs}})
+            : @Test::More::EXPORT,
+        qw<
+            $TODO
+            all_done
+            bail_on_fail
+            die_on_fail
+            explain
+            always_explain
+            last_test_failed
+            restore_fail
+            set_failure_handler
+            show
+            always_show
+        >
+    );
+}
 
-=head1 VERSION
+sub import {
+    my $bail_set = 0;
 
-Version 0.33
+    my %modules_to_load = map { $_ => 1 } qw/
+        Test::Differences
+        Test::Exception
+        Test::Deep
+        Test::Warn
+    /;
+    warnings->import;
+    strict->import;
+    eval "use Data::Dumper::Names 0.03";
+    $DATA_DUMPER_NAMES_INSTALLED = !$@;
 
-=cut
+    if ( $ENV{BAIL_ON_FAIL} ) {
+        $bail_set = 1;
+        bail_on_fail();
+    }
+    if ( !$bail_set and $ENV{DIE_ON_FAIL} ) {
+        die_on_fail();
+    }
+    for my $i ( 0 .. $#_ ) {
+        if ( 'bail' eq $_[$i] ) {
+            splice @_, $i, 1;
+            bail_on_fail();
+            $bail_set = 1;
+            last;
+        }
+    }
+    my $caller = caller;
+    for my $i ( 0 .. $#_ ) {
+        if ( 'timeit' eq $_[$i] ) {
+            splice @_, $i, 1;
+            no strict;
+            *{"${caller}::timeit"} = \&timeit;
+            last;
+        }
+    }
+
+    my %exclude_symbol;
+    my $i = 0;
+
+    foreach my $do_not_import_by_default (qw/blessed reftype/) {
+        if ( grep { $_ eq $do_not_import_by_default } @_ ) {
+            @_ = grep { $_ ne $do_not_import_by_default } @_;
+        }
+        else {
+            $exclude_symbol{$do_not_import_by_default} = 1;
+        }
+    }
+
+    while ($i < @_) {
+        if ( !$bail_set and ( 'die' eq $_[$i] ) ) {
+            splice @_, $i, 1;
+            die_on_fail();
+            $i = 0;
+            next;
+        }
+        if ( $_[$i] =~ /^-(.*)/ ) {
+            my $module = $1;
+            splice @_, $i, 1;
+            unless (exists $modules_to_load{$module}) {
+                require Carp;
+                Carp::croak("Cannot remove non-existent Test::Module ($module)");
+            }
+            delete $modules_to_load{$module};
+            $i = 0;
+            next;
+        }
+        if ( $_[$i] =~ /^!(.*)/ ) {
+            splice @_, $i, 1;
+            $exclude_symbol{$1} = 1;
+            $i = 0;
+            next;
+        }
+        if ( 'defer_plan' eq $_[$i] ) {
+            require Carp;
+            Carp::carp(<<'END') unless $ENV{DO_NOT_WARN_ON_DEFER_PLAN};
+defer_plan() is deprecated and will be removed in a future release of
+Test::Most. It's functionality is provided by Test::More's done_testing(),
+first added in 2009 (0.88).
+END
+            splice @_, $i, 1;
+
+            my $builder = Test::Builder->new;
+
+            # XXX I don't like setting this directly, but
+            # Test::Builder::has_plan isn't public
+            $builder->{Have_Plan}               = 1;
+            $builder->{TEST_MOST_deferred_plan} = 1;
+            $builder->{TEST_MOST_all_done}      = 0;
+            $i = 0;
+            next;
+        }
+        $i++;
+    }
+    foreach my $module (keys %modules_to_load) {
+        eval "use $module";
+
+        if ( my $error = $@) {
+            require Carp;
+            Carp::croak($error);
+        }
+        no strict 'refs';
+        # Note: export_to_level would be better here.
+        push @EXPORT => grep { !$exclude_symbol{$_} } @{"${module}::EXPORT"};
+    }
+
+    # 'magic' goto to avoid updating the callstack
+    goto &Test::Builder::Module::import;
+}
+
+sub explain {
+    _explain(\&Test::More::note, @_);
+}
+
+
+sub timeit(&;$) {
+    my ( $code, $message ) = @_;
+    unless($HAVE_TIME_HIRES) {
+        Test::Most::diag("timeit: Time::HiRes not installed");
+        $code->();
+    }
+    if ( !$message ) {
+        my ( $package, $filename, $line ) = caller;
+        $message = "$filename line $line";
+    }
+    my $start = [Time::HiRes::gettimeofday()];
+    $code->();
+    explain(
+        sprintf "$message: took %s seconds" => Time::HiRes::tv_interval($start) );
+}
+
+sub always_explain {
+    _explain(\&Test::More::diag, @_);
+}
+
+sub _explain {
+    my $diag = shift;
+    no warnings 'once';
+    $diag->(
+        map {
+            ref $_
+              ? do {
+                require Data::Dumper;
+                local $Data::Dumper::Indent   = 1;
+                local $Data::Dumper::Sortkeys = 1;
+                local $Data::Dumper::Terse    = 1;
+                Data::Dumper::Dumper($_);
+              }
+              : $_
+          } @_
+    );
+}
+
+sub show {
+    _show(\&Test::More::note, @_);
+}
+
+sub always_show {
+    _show(\&Test::More::diag, @_);
+}
+
+sub _show {
+    unless ( $DATA_DUMPER_NAMES_INSTALLED ) {
+        require Carp;
+	Carp::carp("Data::Dumper::Names 0.03 not found.  Use explain() instead of show()");
+        goto &_explain;
+    }
+    my $diag = shift;
+    no warnings 'once';
+    local $Data::Dumper::Indent         = 1;
+    local $Data::Dumper::Sortkeys       = 1;
+    local $Data::Dumper::Names::UpLevel = $Data::Dumper::Names::UpLevel + 2;
+    $diag->(Data::Dumper::Names::Dumper(@_));
+}
+
+sub die_on_fail {
+    set_failure_handler( sub { throw_failure } );
+}
+
+sub bail_on_fail {
+    set_failure_handler(
+        sub { Test::More::BAIL_OUT("Test failed.  BAIL OUT!.\n") } );
+}
+
+sub restore_fail {
+    no warnings 'redefine';
+    *Test::Builder::ok = $OK_FUNC;
+}
+
+sub all_done {
+   my $builder = Test::Builder->new;
+   if ($builder->{TEST_MOST_deferred_plan}) {
+       $builder->{TEST_MOST_all_done} = 1;
+       $builder->expected_tests(@_ ? $_[0] : $builder->current_test);
+   }
+}
+
+
+sub set_failure_handler {
+    my $action = shift;
+    no warnings 'redefine';
+    Test::Builder->new->{TEST_MOST_failure_action} = $action; # for DESTROY
+    *Test::Builder::ok = sub {
+        local $Test::Builder::Level = $Test::Builder::Level + 1;
+        my $builder = $_[0];
+        if ( $builder->{TEST_MOST_test_failed} ) {
+            $builder->{TEST_MOST_test_failed} = 0;
+            $action->($builder);
+        }
+        $builder->{TEST_MOST_test_failed} = 0;
+        my $result = $OK_FUNC->(@_);
+        $builder->{TEST_MOST_test_failed} = !( $builder->summary )[-1];
+        return $result;
+    };
+}
+
+{
+    no warnings 'redefine';
+
+    # we need this because if the failure is on the final test, we won't have
+    # a subsequent test triggering the behavior.
+    sub Test::Builder::DESTROY {
+        my $builder = $_[0];
+        if ( $builder->{TEST_MOST_test_failed} ) {
+            ( $builder->{TEST_MOST_failure_action} || sub {} )->();
+        }
+    }
+}
+
+sub _deferred_plan_handler {
+   my $builder = Test::Builder->new;
+   if ($builder->{TEST_MOST_deferred_plan} and !$builder->{TEST_MOST_all_done})
+   {
+       $builder->expected_tests($builder->current_test + 1);
+   }
+}
+
+# This should work because the END block defined by Test::Builder should be
+# guaranteed to be run before t one, since we use'd Test::Builder way up top.
+# The other two alternatives would be either to replace Test::Builder::_ending
+# similar to how we did Test::Builder::ok, or to call Test::Builder::no_ending
+# and basically rewrite _ending in our own image.  Neither is very palatable,
+# considering _ending's initial underscore.
+
+END {
+   _deferred_plan_handler();
+}
+
+1;
+__END__
+
+=head1 NAME
+
+Test::Most - Most commonly needed test functions and features.
+
+=head1 VERSION
 
-our $VERSION = '0.33';
-$VERSION = eval $VERSION;
+Version 0.34
 
 =head1 SYNOPSIS
 
@@ -330,6 +609,10 @@ fully-qualified version or request it on the command line:
 
     use Test::Most 'blessed';
 
+Note that as of version C<0.34>, C<reftype> is also excluded from
+C<Test::Deep>'s import list. This was causing issues with people trying to use
+C<Scalar::Util>'s C<reftype> function.
+
 =head2 Excluding Test Modules
 
 Sometimes you want a exclude a particular test module.  For example,
@@ -349,15 +632,16 @@ for more information.
 =head2 Excluding Test Symbols
 
 Sometimes you don't want to exclude an entire test module, but just a
-particular symbol that is causing issues (e.g. see the 'blessed' example
-above). You can exclude the symbol(s) in the standard way, by specifying the
-symbol in the import list with a '!' in front:
+particular symbol that is causing issues You can exclude the symbol(s) in the
+standard way, by specifying the symbol in the import list with a '!' in front:
 
-    use Test::Most tests => 42, '!blessed';
+    use Test::Most tests => 42, '!throws_ok';
 
 =head2 Deferred plans
 
-B<DEPRECATED>.  Use C<done_testing()> from L<Test::More> instead.
+B<DEPRECATED> and will be removed in some future release of this module.
+Using C<defer_plan> will C<carp()>. Use C<done_testing()> from L<Test::More>
+instead.
 
  use Test::Most qw<defer_plan>;
  use My::Tests;
@@ -436,265 +720,6 @@ it's a great and useful module.
 
 =cut
 
-BEGIN {
-    @ISA    = qw(Test::Builder::Module);
-    @EXPORT = (
-        @Test::More::EXPORT, 
-        qw<
-            all_done
-            bail_on_fail
-            die_on_fail
-            explain
-            always_explain
-            last_test_failed
-            restore_fail
-            set_failure_handler
-            show
-            always_show
-        >
-    );
-}
-
-sub import {
-    my $bail_set = 0;
-
-    my %modules_to_load = map { $_ => 1 } qw/
-        Test::Differences
-        Test::Exception
-        Test::Deep
-        Test::Warn
-    /;
-    warnings->import;
-    strict->import;
-    eval "use Data::Dumper::Names 0.03";
-    $DATA_DUMPER_NAMES_INSTALLED = !$@;
-
-    if ( $ENV{BAIL_ON_FAIL} ) {
-        $bail_set = 1;
-        bail_on_fail();
-    }
-    if ( !$bail_set and $ENV{DIE_ON_FAIL} ) {
-        die_on_fail();
-    }
-    for my $i ( 0 .. $#_ ) {
-        if ( 'bail' eq $_[$i] ) {
-            splice @_, $i, 1;
-            bail_on_fail();
-            $bail_set = 1;
-            last;
-        }
-    }
-    my $caller = caller;
-    for my $i ( 0 .. $#_ ) {
-        if ( 'timeit' eq $_[$i] ) {
-            splice @_, $i, 1;
-            no strict;
-            *{"${caller}::timeit"} = \&timeit;
-            last;
-        }
-    }
-
-    my %exclude_symbol;
-    my $i = 0;
-
-    if ( grep { $_ eq 'blessed' } @_ ) {
-        @_ = grep { $_ ne 'blessed' } @_;
-    }
-    else {
-        $exclude_symbol{blessed} = 1;
-    }
-    while ($i < @_) {
-        if ( !$bail_set and ( 'die' eq $_[$i] ) ) {
-            splice @_, $i, 1;
-            die_on_fail();
-            $i = 0;
-            next;
-        }
-        if ( $_[$i] =~ /^-(.*)/ ) {
-            my $module = $1;
-            splice @_, $i, 1;
-            unless (exists $modules_to_load{$module}) {
-                require Carp;
-                Carp::croak("Cannot remove non-existent Test::Module ($module)");
-            }
-            delete $modules_to_load{$module};
-            $i = 0;
-            next;
-        }
-        if ( $_[$i] =~ /^!(.*)/ ) {
-            splice @_, $i, 1;
-            $exclude_symbol{$1} = 1;
-            $i = 0;
-            next;
-        }
-        if ( 'defer_plan' eq $_[$i] ) {
-            splice @_, $i, 1;
-
-            my $builder = Test::Builder->new;
-            $builder->{Have_Plan} = 1
-              ; # don't like setting this directly, but Test::Builder::has_plan doe
-            $builder->{TEST_MOST_deferred_plan} = 1;
-            $builder->{TEST_MOST_all_done}      = 0;
-            $i = 0;
-            next;
-        }
-        $i++;
-    }
-    foreach my $module (keys %modules_to_load) {
-        eval "use $module";
-
-        if ( my $error = $@) {
-            require Carp;
-            Carp::croak($error);
-        }
-        no strict 'refs';
-        # Note: export_to_level would be better here.
-        push @EXPORT => grep { !$exclude_symbol{$_} } @{"${module}::EXPORT"};
-    }
-
-    # 'magic' goto to avoid updating the callstack
-    goto &Test::Builder::Module::import;
-}
-
-sub explain {
-    _explain(\&Test::More::note, @_);
-}
-
-
-sub timeit(&;$) {
-    my ( $code, $message ) = @_;
-    unless($HAVE_TIME_HIRES) {
-        Test::Most::diag("timeit: Time::HiRes not installed");
-        $code->();
-    }
-    if ( !$message ) {
-        my ( $package, $filename, $line ) = caller;
-        $message = "$filename line $line";
-    }
-    my $start = [Time::HiRes::gettimeofday()];
-    $code->();
-    explain(
-        sprintf "$message: took %s seconds" => Time::HiRes::tv_interval($start) );
-}
-
-sub always_explain {
-    _explain(\&Test::More::diag, @_);
-}
-
-sub _explain {
-    my $diag = shift;
-    no warnings 'once';
-    $diag->(
-        map {
-            ref $_
-              ? do {
-                require Data::Dumper;
-                local $Data::Dumper::Indent   = 1;
-                local $Data::Dumper::Sortkeys = 1;
-                local $Data::Dumper::Terse    = 1;
-                Data::Dumper::Dumper($_);
-              }
-              : $_
-          } @_
-    );
-}
-
-sub show {
-    _show(\&Test::More::note, @_);
-}
-
-sub always_show {
-    _show(\&Test::More::diag, @_);
-}
-
-sub _show {
-    unless ( $DATA_DUMPER_NAMES_INSTALLED ) {
-        require Carp;
-	Carp::carp("Data::Dumper::Names 0.03 not found.  Use explain() instead of show()");
-        goto &_explain;
-    }
-    my $diag = shift;
-    no warnings 'once';
-    local $Data::Dumper::Indent         = 1;
-    local $Data::Dumper::Sortkeys       = 1;
-    local $Data::Dumper::Names::UpLevel = $Data::Dumper::Names::UpLevel + 2;
-    $diag->(Data::Dumper::Names::Dumper(@_));
-}
-
-sub die_on_fail {
-    set_failure_handler( sub { throw_failure } );
-}
-
-sub bail_on_fail {
-    set_failure_handler(
-        sub { Test::More::BAIL_OUT("Test failed.  BAIL OUT!.\n") } );
-}
-
-sub restore_fail {
-    no warnings 'redefine';
-    *Test::Builder::ok = $OK_FUNC;
-}
-
-sub all_done {
-   my $builder = Test::Builder->new;
-   if ($builder->{TEST_MOST_deferred_plan}) {
-       $builder->{TEST_MOST_all_done} = 1;
-       $builder->expected_tests(@_ ? $_[0] : $builder->current_test);
-   }
-}
-
-
-sub set_failure_handler {
-    my $action = shift;
-    no warnings 'redefine';
-    Test::Builder->new->{TEST_MOST_failure_action} = $action; # for DESTROY
-    *Test::Builder::ok = sub {
-        local $Test::Builder::Level = $Test::Builder::Level + 1;
-        my $builder = $_[0];
-        if ( $builder->{TEST_MOST_test_failed} ) {
-            $builder->{TEST_MOST_test_failed} = 0;
-            $action->($builder);
-        }
-        $builder->{TEST_MOST_test_failed} = 0;
-        my $result = $OK_FUNC->(@_);
-        $builder->{TEST_MOST_test_failed} = !( $builder->summary )[-1];
-        return $result;
-    };
-}
-
-{
-    no warnings 'redefine';
-
-    # we need this because if the failure is on the final test, we won't have
-    # a subsequent test triggering the behavior.
-    sub Test::Builder::DESTROY {
-        my $builder = $_[0];
-        if ( $builder->{TEST_MOST_test_failed} ) {
-            ( $builder->{TEST_MOST_failure_action} || sub {} )->();
-        }
-    }
-}
-
-sub _deferred_plan_handler {
-   my $builder = Test::Builder->new;
-   if ($builder->{TEST_MOST_deferred_plan} and !$builder->{TEST_MOST_all_done})
-   {
-       $builder->expected_tests($builder->current_test + 1);
-   }
-}
-
-# This should work because the END block defined by Test::Builder should be
-# guaranteed to be run before t one, since we use'd Test::Builder way up top.
-# The other two alternatives would be either to replace Test::Builder::_ending
-# similar to how we did Test::Builder::ok, or to call Test::Builder::no_ending
-# and basically rewrite _ending in our own image.  Neither is very palatable,
-# considering _ending's initial underscore.
-
-END {
-   _deferred_plan_handler();
-}
-
-1;
 
 =head1 AUTHOR
 
@@ -1,5 +1,6 @@
 #!/usr/bin/perl
 
+BEGIN { $ENV{DO_NOT_WARN_ON_DEFER_PLAN} = 1 }
 use lib 'lib', 't/lib';
 use Test::Most qw<defer_plan>;