From: Ash Berlin Date: Tue, 4 Mar 2008 14:13:17 +0000 (+0000) Subject: Make tests more resilient X-Git-Tag: v1.001000~31 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=35ef509e81709f89dda31b0ecefa0f88e637b69a;p=p5sagit%2FClass-C3-Componentised.git Make tests more resilient --- diff --git a/Changes b/Changes index c7ffac8..d69377d 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,8 @@ Revision history for Class-C3-Componentised +1.0002 4 Mar 2008 + Make tests more resilient + 1.0001 11 Aug 2007 Add missing dep on Test::Exception diff --git a/lib/Class/C3/Componentised.pm b/lib/Class/C3/Componentised.pm index b40dfd0..1cbbe13 100644 --- a/lib/Class/C3/Componentised.pm +++ b/lib/Class/C3/Componentised.pm @@ -146,18 +146,6 @@ sub ensure_class_found { Class::Inspector->installed($f_class); } -# Returns a true value if the specified class is installed and loaded -# successfully, throws an exception if the class is found but not loaded -# successfully, and false if the class is not installed -sub _load_optional_class { - my ($class, $f_class) = @_; - if ($class->ensure_class_found($f_class)) { - $class->ensure_class_loaded($f_class); - return 1; - } else { - return 0; - } -} =head2 inject_base diff --git a/t/01-basic.t b/t/01-basic.t index 0a09da6..ca06d35 100644 --- a/t/01-basic.t +++ b/t/01-basic.t @@ -2,18 +2,23 @@ use strict; use warnings; use FindBin; -use lib "$FindBin::Bin/lib"; - use Test::More; use Test::Exception; +use lib "$FindBin::Bin/lib"; + + plan tests => 3; use_ok('MyModule'); MyModule->load_components('Foo'); -throws_ok { MyModule->load_components('+Foo'); } qr/^Can't locate Foo.pm in \@INC/; +# Clear down inc so ppl dont mess us up with installing modules that we +# expect not to exist +@INC = (); + +throws_ok { MyModule->load_components('+ClassC3ComponentFooThatShouldntExist'); } qr/^Can't locate ClassC3ComponentFooThatShouldntExist.pm in \@INC/; is(MyModule->new->message, "Foo MyModule", "it worked");