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

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

commit 9e9e77eb2dc724302f3326689f2fb7805c7988d7
Author: Graham Knop <ha...@haarg.org>
Date:   Sat Dec 3 14:57:51 2016 -0500

    fix asserters for oddly named attributes
---
 lib/Method/Generate/Accessor.pm |  4 ++--
 t/accessor-mixed.t              | 14 ++++++++++++++
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/lib/Method/Generate/Accessor.pm b/lib/Method/Generate/Accessor.pm
index 90bd92b..3918cbc 100644
--- a/lib/Method/Generate/Accessor.pm
+++ b/lib/Method/Generate/Accessor.pm
@@ -631,11 +631,11 @@ sub _generate_getset {
 
 sub _generate_asserter {
   my ($self, $name, $spec) = @_;
-
+  my $name_str = quotify($name);
   "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}' but it is not 
set\");\n"
+   ."    or Carp::croak('Attempted to access '.${name_str}.' but it is not 
set');\n"
    ."  \$val;\n"
    ."}\n";
 }
diff --git a/t/accessor-mixed.t b/t/accessor-mixed.t
index efc4d9a..a97df65 100644
--- a/t/accessor-mixed.t
+++ b/t/accessor-mixed.t
@@ -63,4 +63,18 @@ is_deeply(
   }
 }
 
+{
+  package NWFG;
+  use Moo;
+  ::is ::exception {
+    has qq{odd"na;me\n} => (
+      is => 'bare',
+      map +($_ => 'attr_'.$_),
+        qw(accessor reader writer predicate clearer asserter)
+    );
+  }, undef,
+    'all accessor methods work with oddly named attribute';
+}
+
+
 done_testing;

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

_______________________________________________
Pkg-perl-cvs-commits mailing list
Pkg-perl-cvs-commits@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-perl-cvs-commits

Reply via email to