}
coderef = SvRV(coderef);
+
+ /* sub is still being compiled */
+ if (!CvGV(coderef)) {
+ return 0;
+ }
+
/* I think this only gets triggered with a mangled coderef, but if
we hit it without the guard, we segfault. The slightly odd return
value strikes me as an improvement (mst)
use strict;
use warnings;
-use Test::More;
+use Test::More tests => 6;
+use Sub::Name 'subname';
BEGIN {
$^P &= ~0x200; # Don't munger anonymous sub names
- if ( eval 'use Sub::Name qw(subname); 1;' ) {
- plan tests => 5;
- }
- else {
- plan skip_all => 'These tests require Sub::Name';
- }
}
BEGIN { use_ok("Class::MOP") }
require Class::MOP::Method;
code_name_is( \&Class::MOP::Method::name, "Class::MOP::Method", "name" );
+{
+ package Foo;
+
+ sub MODIFY_CODE_ATTRIBUTES {
+ my ($class, $code) = @_;
+ ::ok(!Class::MOP::get_code_info($code), "no name for a coderef that's still compiling");
+ return ();
+ }
+
+ sub foo : Bar {}
+}