6 use Test::More qw/no_plan/;
14 sub hey { $results{base}++ }
17 for my $wrap (qw(before after)) {
18 my $meta = Class::MOP::Class->create_anon_class(
19 superclasses => ['Base', 'Class::MOP::Object']
21 my $alter = "add_${wrap}_method_modifier";
22 $meta->$alter('hey' => sub {
24 $_ = 'barf'; # 'barf' would replace the cached wrapper subref
28 my $o = $meta->get_meta_instance->create_instance;
32 $o->hey; # this would die with 'Can't use string ("barf") as a subroutine ref while "strict refs" in use'
33 } 'wrapped doesn\'t die when $_ gets changed';
34 is_deeply(\%results, {base=>2,wrapped=>2});
38 my $meta = Class::MOP::Class->create_anon_class(
39 superclasses => ['Base', 'Class::MOP::Object']
41 for my $wrap (qw(before after)) {
42 my $alter = "add_${wrap}_method_modifier";
43 $meta->$alter('hey' => sub {
45 $_ = 'barf'; # 'barf' would replace the cached wrapper subref
50 my $o = $meta->get_meta_instance->create_instance;
54 $o->hey; # this would die with 'Can't use string ("barf") as a subroutine ref while "strict refs" in use'
55 } 'double-wrapped doesn\'t die when $_ gets changed';
56 is_deeply(\%results, {base=>2,wrapped=>4});