[libdist-zilla-util-configdumper-perl] 06/06: make config_dumper(REF) go bang

Florian Schlichting fsfs at moszumanska.debian.org
Sat Nov 11 15:43:56 UTC 2017


This is an automated email from the git hooks/post-receive script.

fsfs pushed a commit to annotated tag 0.003003-source
in repository libdist-zilla-util-configdumper-perl.

commit 5fe4bcf0446bf1d7a8246378513b86de1f5908bd
Author: Kent Fredric <kentfredric at gmail.com>
Date:   Sun Aug 31 02:18:42 2014 +1200

    make config_dumper(REF) go bang
---
 Changes                             |  3 +++
 lib/Dist/Zilla/Util/ConfigDumper.pm |  6 ++++++
 t/bang_on_ref.t                     | 39 +++++++++++++++++++++++++++++++++++++
 3 files changed, 48 insertions(+)

diff --git a/Changes b/Changes
index 97c512f..8b9c648 100644
--- a/Changes
+++ b/Changes
@@ -1,6 +1,9 @@
 Release history for Dist-Zilla-Util-ConfigDumper
 
 {{$NEXT}}
+ [Bugfix]
+ - Croak if __PACKAGE__ is a ref.
+
  [Metadata]
  - author = kentnl
 
diff --git a/lib/Dist/Zilla/Util/ConfigDumper.pm b/lib/Dist/Zilla/Util/ConfigDumper.pm
index d2455b2..f8a6dba 100644
--- a/lib/Dist/Zilla/Util/ConfigDumper.pm
+++ b/lib/Dist/Zilla/Util/ConfigDumper.pm
@@ -57,6 +57,12 @@ Except with some extra "things dun goofed" handling.
 
 sub config_dumper {
   my ( $package, @methodnames ) = @_;
+  if ( not defined $package or ref $package ) {
+    ## no critic (ValuesAndExpressions::RequireInterpolationOfMetachars)
+    croak('config_dumper(__PACKAGE__, @recipie ): Arg 1 must not be ref or undef');
+    ## use critic
+  }
+
   my (@tests) = map { _mk_test( $package, $_ ) } @methodnames;
   my $CFG_PACKAGE = __PACKAGE__;
   return sub {
diff --git a/t/bang_on_ref.t b/t/bang_on_ref.t
new file mode 100644
index 0000000..ea3b89e
--- /dev/null
+++ b/t/bang_on_ref.t
@@ -0,0 +1,39 @@
+use strict;
+use warnings;
+
+use Test::More;
+use Test::DZil qw( simple_ini );
+use Dist::Zilla::Util::Test::KENTNL 1.001 qw( dztest );
+
+# ABSTRACT: Make sure plugins do what they say they'll do
+
+require Moose;
+require Dist::Zilla::Role::Plugin;
+require Dist::Zilla::Plugin::Bootstrap::lib;
+require Dist::Zilla::Plugin::GatherDir;
+require Dist::Zilla::Plugin::MetaConfig;
+
+my $t   = dztest();
+my $pn  = 'TestPlugin';
+my $fpn = 'Dist::Zilla::Plugin::' . $pn;
+
+$t->add_file( 'dist.ini', simple_ini( ['Bootstrap::lib'], ['GatherDir'], ['MetaConfig'], [$pn], ) );
+$t->add_file( 'lib/Dist/Zilla/Plugin/' . $pn . '.pm', <<"EOF");
+package $fpn;
+
+use Moose qw( has around with );
+use Dist::Zilla::Util::ConfigDumper qw( config_dumper );
+with 'Dist::Zilla::Role::Plugin';
+
+has 'attr' => ( is => 'ro', 'lazy' => 1, default => sub { 'I have value, my life has meaning' } );
+
+around dump_config => config_dumper({});
+
+__PACKAGE__->meta->make_immutable;
+no Moose;
+
+1;
+EOF
+isnt( $t->safe_build, undef, 'Ref == bang' );
+done_testing;
+

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libdist-zilla-util-configdumper-perl.git



More information about the Pkg-perl-cvs-commits mailing list