]> git.vpit.fr Git - perl/modules/subs-auto.git/commitdiff
Fix default package
authorVincent Pit <vince@profvince.com>
Sun, 25 Jul 2010 17:57:24 +0000 (19:57 +0200)
committerVincent Pit <vince@profvince.com>
Sun, 25 Jul 2010 17:57:24 +0000 (19:57 +0200)
lib/subs/auto.pm
t/11-pkg.t

index c0be5aa09b8ed0b5163cf9281b9d2e7fda0040db..deeec16cf416a8bcb033925922d3f477db8b4e77 100644 (file)
@@ -202,7 +202,7 @@ sub import {
  }
  my %args = @_;
 
  }
  my %args = @_;
 
- my $cur = (caller 1)[0];
+ my $cur = caller;
  my $in  = _validate_pkg $args{in}, $cur;
  ++$pkgs{$in};
  {
  my $in  = _validate_pkg $args{in}, $cur;
  ++$pkgs{$in};
  {
index f84e31dcf62de3d483c83e6861c2c172b5dae0aa..4999377352ced5327bacb0548b11e5bebb599dfe 100644 (file)
@@ -8,67 +8,115 @@ use Test::More tests => 16;
 our $foo;
 
 {
 our $foo;
 
 {
- use subs::auto in => 'subs::auto::Test::Pkg';
-
- eval { subs::auto::Test::Pkg::foo 1 };
- is($@, '', 'compiled to subs::auto::Test::Pkg::foo(1)');
- is($foo, 3, 'subs::auto::Test::Pkg::foo was really called');
-
- {
-  use subs::auto;
-
-  eval { foo 2 };
-  is($@, '', 'compiled to foo(2)');
-  is($foo, 4, 'main::foo was really called');
+ eval q{
+  use subs::auto in => 'subs::auto::Test::Pkg';
+  subs::auto::Test::Pkg::foo 1
+ };
+ my $err = $@;
+ is($err, '', 'compiled to subs::auto::Test::Pkg::foo(1)');
+ is($foo, 3,  'subs::auto::Test::Pkg::foo was really called');
+}
 
 
-  eval { subs::auto::Test::Pkg::foo 3 };
-  is($@, '', 'compiled to subs::auto::Test::Pkg::foo(3)');
-  is($foo, 9, 'subs::auto::Test::Pkg::foo was really called');
+{
+ eval q{
+  use subs::auto in => 'subs::auto::Test::Pkg';
+  {
+   use subs::auto;
+   foo 2
+  }
+ };
+ my $err = $@;
+ no warnings 'uninitialized';
+ is($err, '', 'compiled to foo(2)');
+ is($foo, 4,  'main::foo was really called');
+}
 
 
+{
+ eval q{
+  use subs::auto in => 'subs::auto::Test::Pkg';
   {
   {
-   package subs::auto::Test::Pkg;
+   use subs::auto;
+   subs::auto::Test::Pkg::foo 3;
+  }
+ };
+ my $err = $@;
+ no warnings 'uninitialized';
+ is($err, '', 'compiled to subs::auto::Test::Pkg::foo(3)');
+ is($foo, 9,  'subs::auto::Test::Pkg::foo was really called');
+}
 
 
-   eval { foo 4 };
-   Test::More::is($@, '', 'compiled to foo(4)');
-   Test::More::is($foo, 12, 'subs::auto::Test::Pkg::foo was really called');
+{
+ eval q{
+  use subs::auto in => 'subs::auto::Test::Pkg';
+  {
+   use subs::auto;
+   {
+    package subs::auto::Test::Pkg;
+    foo 4
+   }
+  }
+ };
+ my $err = $@;
+ no warnings 'uninitialized';
+ Test::More::is($err, '', 'compiled to foo(4)');
+ Test::More::is($foo, 12, 'subs::auto::Test::Pkg::foo was really called');
+}
 
 
-   eval { main::foo 5 };
-   Test::More::is($@, '', 'compiled to main::foo(5)');
-   Test::More::is($foo, 10, 'main::foo was really called');
+{
+ eval q{
+  use subs::auto in => 'subs::auto::Test::Pkg';
+  {
+   use subs::auto;
+   {
+    package subs::auto::Test::Pkg;
+    main::foo 5
+   }
   }
   }
- }
+ };
+ my $err = $@;
+ no warnings 'uninitialized';
+ Test::More::is($err, '', 'compiled to main::foo(5)');
+ Test::More::is($foo, 10, 'main::foo was really called');
 }
 
 {
  package subs::auto::Test::Pkg;
 
 }
 
 {
  package subs::auto::Test::Pkg;
 
- use subs::auto;
-
- eval { foo 6 };
- Test::More::is($@, '', 'compiled to foo(6)');
+ eval q{
+  use subs::auto;
+  foo 6
+ };
+ my $err = $@;
+ no warnings 'uninitialized';
+ Test::More::is($err, '', 'compiled to foo(6)');
  Test::More::is($foo, 18, 'subs::auto::Test::Pkg::foo was really called');
 }
 
 {
  Test::More::is($foo, 18, 'subs::auto::Test::Pkg::foo was really called');
 }
 
 {
- use subs::auto in => '::';
-
- eval { foo 7 };
- is($@, '', 'compiled to foo(7)');
+ eval q{
+  use subs::auto in => '::';
+  foo 7
+ };
+ my $err = $@;
+ no warnings 'uninitialized';
+ is($err, '', 'compiled to foo(7)');
  is($foo, 14, 'main::foo was really called');
 }
 
 {
  package subs::auto::Test;
 
  is($foo, 14, 'main::foo was really called');
 }
 
 {
  package subs::auto::Test;
 
- use subs::auto in => '::Pkg';
-
- {
-  package subs::auto::Test::Pkg;
-
-  eval { foo 8 };
-  Test::More::is($@, '', 'compiled to foo(8)');
-  Test::More::is($foo, 24, 'subs::auto::Test::Pkg::foo was really called');
- }
+ eval q{
+  use subs::auto in => '::Pkg';
+  {
+   package subs::auto::Test::Pkg;
+   foo 8;
+  }
+ };
+ my $err = $@;
+ no warnings 'uninitialized';
+ Test::More::is($err, '', 'compiled to foo(8)');
+ Test::More::is($foo, 24, 'subs::auto::Test::Pkg::foo was really called');
 }
 
 sub foo {
 }
 
 sub foo {