Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 0ccb26a8b6
Fetching contributors…

Cannot retrieve contributors at this time

91 lines (76 sloc) 1.635 kb
#!perl
# this test comes from Class::Method::Modifiers
use strict;
use warnings;
use Test::More tests => 2;
use FindBin qw($Bin);
use lib "$Bin/../example/lib";
my @seen;
my @expected = qw/ before
around-before
orig
around-after
after /;
my $child = Child->new();
$child->orig();
is_deeply(\@seen, \@expected, "multiple modifiers in one class");
@seen = ();
@expected = qw/ beforer around-beforer
before around-before
orig
around-after after
around-afterer afterer /;
my $childer = Childer->new();
$childer->orig();
is_deeply(\@seen, \@expected, "multiple modifiers subclassed with multiple modifiers");
BEGIN
{
package Parent;
sub new { bless {}, shift }
sub orig
{
push @seen, 'orig';
}
}
BEGIN
{
package Child;
our @ISA = 'Parent';
use Method::Modifiers;
after 'orig' => sub
{
push @seen, 'after';
};
around 'orig' => sub
{
my $orig = shift;
push @seen, 'around-before';
$orig->();
push @seen, 'around-after';
};
before 'orig' => sub
{
push @seen, 'before';
};
}
BEGIN
{
package Childer;
our @ISA = 'Child';
use Method::Modifiers;
after 'orig' => sub
{
push @seen, 'afterer';
};
around 'orig' => sub
{
my $orig = shift;
push @seen, 'around-beforer';
$orig->();
push @seen, 'around-afterer';
};
before 'orig' => sub
{
push @seen, 'beforer';
};
}
Jump to Line
Something went wrong with that request. Please try again.