6 use Test::More tests => 8;
8 use with \bless {}, 'with::Mock';
11 sub with::Mock::pop { }
14 sub with::Mock::dongs { CORE::shift; $_[0] + $_[1] }
15 sub hlagh { 2 * $_[0] + $_[1] }
16 sub with::Mock::boner { CORE::shift; $_[0] + 2 * $_[1] }
20 push @a, 2; # with::corewrap, defaulting to CORE
21 is $a[1], 2, 'CORE::push';
22 shift @a; # with::corewrap, function in caller namespace
23 is $a[1], 2, 'main::shift';
24 pop @a; # with::corewrap, method call
25 is $a[1], 2, 'with::Mock::pop';
26 my $x = durrr @a; # with::subwrap, function in caller namespace
27 is $x, 79, 'main::durrr';
28 my $y = dongs @a; # with::subwrap, method call
29 is $y, 3, 'with::Mock::dongs';
30 my $z = hlagh @a; # with::defer, function in caller namespace
31 is $z, 4, 'main::hlagh';
32 my $t = boner @a; # with::defer, method call
33 is $t, 5, 'with::Mock::boner';
34 eval { zogzog @a }; # with::defer, no such fonction
35 like $@, qr/Undefined\s+subroutine/, 'no zogzog';