diff options
author | Jesse Luehrs <doy@tozt.net> | 2011-12-19 14:02:23 -0600 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2011-12-19 14:03:29 -0600 |
commit | cb8ebfeb3c38036bb8dd0b5b7d0fcd4274101ffa (patch) | |
tree | 1defd1e72b84f795bf5756cd96e99dba7eb20af7 | |
parent | 9963fffa42a8de2e5e5311db2bd892905f0160e1 (diff) | |
download | circular-require-cb8ebfeb3c38036bb8dd0b5b7d0fcd4274101ffa.tar.gz circular-require-cb8ebfeb3c38036bb8dd0b5b7d0fcd4274101ffa.zip |
fix for use base (Exodist)
-rw-r--r-- | Changes | 1 | ||||
-rw-r--r-- | lib/circular/require.pm | 2 | ||||
-rw-r--r-- | t/04-base2.t | 18 | ||||
-rw-r--r-- | t/04/Bar.pm | 7 | ||||
-rw-r--r-- | t/04/Foo.pm | 9 |
5 files changed, 36 insertions, 1 deletions
@@ -1,6 +1,7 @@ Revision history for circular-require {{$NEXT}} + - fix the previous workaround (Exodist) 0.03 2011-07-18 - work around annoying base.pm behavior (reported by wooster) diff --git a/lib/circular/require.pm b/lib/circular/require.pm index 6a8c0be..7bc8552 100644 --- a/lib/circular/require.pm +++ b/lib/circular/require.pm @@ -61,7 +61,7 @@ sub _require { $mod =~ s+[/\\]+::+g; $mod =~ s+\.pm$++; $ret = $saved - ? $saved->($file) : eval "CORE::require($mod)"; + ? $saved->($file) : do { eval "CORE::require $mod" || die $@ }; } else { $ret = $saved ? $saved->($file) : CORE::require($file); diff --git a/t/04-base2.t b/t/04-base2.t new file mode 100644 index 0000000..c0be7a7 --- /dev/null +++ b/t/04-base2.t @@ -0,0 +1,18 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use lib 't/04'; +use Test::More; +use Test::Exception; + +# Test passes if you comment this out +no circular::require; + +use_ok('Foo'); +lives_ok { is( Foo->bar, "bar", "Polymorphism" ) } + "bar() method available on Foo"; + +throws_ok { base->import( 'BadWolf' ) } + qr|Base class package "BadWolf" is empty|, "use base 'Some Bad File' should throw an exception"; + +done_testing; diff --git a/t/04/Bar.pm b/t/04/Bar.pm new file mode 100644 index 0000000..207dc68 --- /dev/null +++ b/t/04/Bar.pm @@ -0,0 +1,7 @@ +package Bar; +use strict; +use warnings; + +sub bar { "bar" } + +1; diff --git a/t/04/Foo.pm b/t/04/Foo.pm new file mode 100644 index 0000000..cfb1bb4 --- /dev/null +++ b/t/04/Foo.pm @@ -0,0 +1,9 @@ +package Foo; +use strict; +use warnings; + +use base 'Bar'; + +sub foo { "foo" } + +1; |