File: 02c_inh_from_grandparent.t

package info (click to toggle)
libsub-wrappackages-perl 2.02-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 292 kB
  • sloc: perl: 664; sh: 3; makefile: 2
file content (29 lines) | stat: -rw-r--r-- 838 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/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)],
    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');