HEX
Server: Apache
System: Linux box5154.bluehost.com 5.14.0-162.23.1.9991722448259.nf.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jul 31 18:11:45 UTC 2024 x86_64
User: almiraso (1849)
PHP: 8.2.31
Disabled: NONE
Upload Files
File: //usr/share/doc/perl-Class-Method-Modifiers/t/011-after-args.t
use strict;
use warnings;
use Test::More 0.88;
use if $ENV{AUTHOR_TESTING}, 'Test::Warnings';

my $after_saw_orig_args = 0;

my $storage = "Foo";
my $child = Child->new();
is($child->orig($storage), "orig", "after didn't affect orig's return");
ok($after_saw_orig_args, "after saw original arguments");

BEGIN
{
    package MyParent;
    sub new { bless {}, shift }
    sub orig
    {
        my $self = shift;
        $_[0] =~ s/Foo/bAR/;
        return "orig";
    }
}

BEGIN
{
    package Child;
    our @ISA = 'MyParent';
    use Class::Method::Modifiers;

    after 'orig' => sub
    {
        my $self = shift;
        my $arg = shift;
        $after_saw_orig_args = $arg eq "bAR";
        return sub { die "somehow a closure was executed" };
    };
}

done_testing;