From: Dave Rolsky Date: Sun, 8 Feb 2009 15:07:54 +0000 (+0000) Subject: add a bunch of tests for is_class_loaded X-Git-Tag: 0.77~16 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7f820be67cd392c550fc314459a8adc0ef5af74f;p=gitmo%2FClass-MOP.git add a bunch of tests for is_class_loaded --- diff --git a/t/083_load_class.t b/t/083_load_class.t index a091147..e93c427 100644 --- a/t/083_load_class.t +++ b/t/083_load_class.t @@ -1,6 +1,6 @@ use strict; use warnings; -use Test::More tests => 29; +use Test::More tests => 33; use Test::Exception; require Class::MOP; @@ -91,3 +91,26 @@ throws_ok { 'the mere mention of TestClassLoaded in the whatever sub does not make us think it has been loaded' ); } +{ + require TestClassLoaded::Sub; + ok( ! Class::MOP::is_class_loaded('TestClassLoaded'), + 'requiring TestClassLoaded::Sub does not make us think TestClassLoaded is loaded' ); +} + +{ + require TestClassLoaded; + ok( Class::MOP::is_class_loaded('TestClassLoaded'), + 'We see that TestClassLoaded is loaded after requiring it (it has methods but no $VERSION or @ISA)' ); +} + +{ + require TestClassLoaded2; + ok( Class::MOP::is_class_loaded('TestClassLoaded2'), + 'We see that TestClassLoaded2 is loaded after requiring it (it has a $VERSION but no methods or @ISA)' ); +} + +{ + require TestClassLoaded3; + ok( Class::MOP::is_class_loaded('TestClassLoaded3'), + 'We see that TestClassLoaded3 is loaded after requiring it (it has an @ISA but no methods or $VERSION)' ); +} diff --git a/t/lib/TestClassLoaded/Sub.pm b/t/lib/TestClassLoaded/Sub.pm new file mode 100644 index 0000000..49a6c17 --- /dev/null +++ b/t/lib/TestClassLoaded/Sub.pm @@ -0,0 +1,7 @@ +package TestClassLoaded::Sub; +use strict; +use warnings; + +sub ver_test { return "TestClassLoaded ver $TestClassLoaded::VERSION" } + +1; diff --git a/t/lib/TestClassLoaded2.pm b/t/lib/TestClassLoaded2.pm new file mode 100644 index 0000000..46c18f9 --- /dev/null +++ b/t/lib/TestClassLoaded2.pm @@ -0,0 +1,8 @@ +package TestClassLoaded2; +use strict; +use warnings; + +our $VERSION = 42; + +1; + diff --git a/t/lib/TestClassLoaded3.pm b/t/lib/TestClassLoaded3.pm new file mode 100644 index 0000000..5fe67eb --- /dev/null +++ b/t/lib/TestClassLoaded3.pm @@ -0,0 +1,8 @@ +package TestClassLoaded3; +use strict; +use warnings; + +our @ISA = 'Foo'; + +1; +