Codebase list libsub-wrappackages-perl / 774804a9-8d5f-49dd-a694-4a1dde68c802/upstream t / 02e_inh_from_grandparent_parent_also_wrapped_order_rev.t
774804a9-8d5f-49dd-a694-4a1dde68c802/upstream

Tree @774804a9-8d5f-49dd-a694-4a1dde68c802/upstream (Download .tar.gz)

02e_inh_from_grandparent_parent_also_wrapped_order_rev.t @774804a9-8d5f-49dd-a694-4a1dde68c802/upstreamraw · history · blame

#!/usr/bin/perl -w

use strict;
use Test::More tests => 5;
use Data::Dumper;

my $pre; my $post;

use lib 't/lib'; use c;
use Sub::WrapPackages (
    packages       => [qw(c b)],
    wrap_inherited => 1,
    pre            => sub { $pre .= join(", ", @_); },
    post           => sub { $post .= join(', ', @_); }
);

my $r = c->a_scalar(94);

is($pre, 'c::a_scalar, c, 94',
  "when wrapping methods inherited from grandparent, pre is good");
is($post, 'c::a_scalar, in sub a_scalar',
  "when wrapping methods inherited from grandparent, post is good");
is($r, 'in sub a_scalar',
  "when wrapping methods inherited from grandparent, return value is good");

is(c->a_context_sensitive(), 'not redefined',
    'overridden grandparent method not redefined');
is(c->b_function(), 'not redefined',
    'overridden parent method not redefined');