[libmoo-perl] 34/43: fix asserter failure message and test

gregor herrmann gregoa at debian.org
Mon Dec 26 17:56:16 UTC 2016


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

gregoa pushed a commit to branch master
in repository libmoo-perl.

commit e52004ec808a462b317b4e3b651c69f6e981ad7d
Author: Graham Knop <haarg at haarg.org>
Date:   Fri Dec 9 08:46:13 2016 -0500

    fix asserter failure message and test
---
 lib/Method/Generate/Accessor.pm | 2 +-
 t/accessor-handles.t            | 9 +++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/lib/Method/Generate/Accessor.pm b/lib/Method/Generate/Accessor.pm
index 2f81458..a31eb71 100644
--- a/lib/Method/Generate/Accessor.pm
+++ b/lib/Method/Generate/Accessor.pm
@@ -638,7 +638,7 @@ sub _generate_asserter {
   "do {\n"
    ."  my \$val = ".$self->_generate_get($name, $spec).";\n"
    ."  ".$self->_generate_simple_has('$_[0]', $name, $spec)."\n"
-   ."    or Carp::croak('Attempted to access '.${name_str}.' but it is not set');\n"
+   ."    or Carp::croak(q{Attempted to access '}.${name_str}.q{' but it is not set});\n"
    ."  \$val;\n"
    ."}\n";
 }
diff --git a/t/accessor-handles.t b/t/accessor-handles.t
index 806c22b..af5af9e 100644
--- a/t/accessor-handles.t
+++ b/t/accessor-handles.t
@@ -66,6 +66,10 @@ use InlineModule (
                 handles => { foobar => '${\\Baz->can("is_passed_undefined")}'},
                 default => sub { undef } );
 
+  has foo8 => (
+    is => 'rw',
+    handles => [ 'foo8_gone' ],
+  );
 }
 
 my $bar = Bar->new(
@@ -88,6 +92,11 @@ is $bar->foobot, 'beep', 'asserter checks for existence not truth, on false valu
 
 is $bar->foobar, 'bar', 'asserter checks for existence not truth, on undef ';
 
+like exception {
+  $bar->foo8_gone;
+}, qr/^Attempted to access 'foo8' but it is not set/,
+  'asserter fails with correct message';
+
 ok(my $e = exception {
   package Baz;
   use Moo;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libmoo-perl.git



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