X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F11-pkg.t;fp=t%2F11-pkg.t;h=bd4ebb3504a069a73664e22e82e99557dcd24063;hb=a458a01af6d6d0e328ffc36afdcbd96628ae2e71;hp=0000000000000000000000000000000000000000;hpb=e76d964d90a17da3e4f61b9d99de3981896f5b4a;p=perl%2Fmodules%2Fsubs-auto.git diff --git a/t/11-pkg.t b/t/11-pkg.t new file mode 100644 index 0000000..bd4ebb3 --- /dev/null +++ b/t/11-pkg.t @@ -0,0 +1,66 @@ +#!perl -T + +use strict; +use warnings; + +use Test::More tests => 12; + +our $foo; + +{ + use subs::auto in => 'subs::auto::Test::Pkg'; + + eval { subs::auto::Test::Pkg::foo 5 }; + is($@, '', 'compiled to subs::auto::Test::Pkg::foo(5)'); + is($foo, 10, 'subs::auto::Test::Pkg::foo was really called'); + + { + use subs::auto; + + eval { foo 3 }; + is($@, '', 'compiled to foo(3)'); + is($foo, 3, 'main::foo was really called'); + + { + package subs::auto::Test::Pkg; + + eval { foo 7 }; + Test::More::is($@, '', 'compiled to foo(7)'); + Test::More::is($foo, 14, 'subs::auto::Test::Pkg::foo was really called'); + + eval { main::foo 9 }; + Test::More::is($@, '', 'compiled to main::foo(9)'); + Test::More::is($foo, 9, 'main::foo was really called'); + } + } +} + +{ + use subs::auto in => '::'; + + eval { foo 11 }; + is($@, '', 'compiled to foo(11)'); + is($foo, 11, 'main::foo was really called'); +} + +{ + package subs::auto::Test; + + use subs::auto in => '::Pkg'; + + { + package subs::auto::Test::Pkg; + + eval { foo 13 }; + Test::More::is($@, '', 'compiled to foo(13)'); + Test::More::is($foo, 26, 'subs::auto::Test::Pkg::foo was really called'); + } +} + +sub foo { + $main::foo = $_[0]; +} + +sub subs::auto::Test::Pkg::foo { + $main::foo = 2 * $_[0]; +}