X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=t%2F01_module.t;h=3f2f33d36f53302961caad53c5e1c464fae9e949;hb=e62017220f259704c70a9144bb8225fe543da4e9;hp=17ce5ec528bde92b0130fe50d8a4e16f75bdf3d8;hpb=28a7e8d3cb0ae70d6eab05e526dc786ff837b1af;p=class_modular.git%2F.git diff --git a/t/01_module.t b/t/01_module.t index 17ce5ec..3f2f33d 100644 --- a/t/01_module.t +++ b/t/01_module.t @@ -1,3 +1,4 @@ +# -*- mode: cperl;-*- # This file is part of Class::Modular and is released under the terms # of the GPL version 2, or any later version at your option. See the # file README and COPYING for more information. @@ -5,10 +6,12 @@ # $Id: $ -use Test::Simple tests => 9; +use Test::More tests => 11; use UNIVERSAL; +use_ok('Class::Modular'); + my $destroy_hit = 0; { @@ -16,17 +19,17 @@ my $destroy_hit = 0; $INC{'Foo.pm'} = '1'; package Foo; + use vars qw(@METHODS); + BEGIN { + @METHODS = qw(blah); + } + use base qw(Class::Modular); - use constant METHODS => 'blah'; sub blah { return 1; } - sub _methods { - return qw(blah); - } - sub _destroy{ $destroy_hit = 1; } @@ -38,7 +41,6 @@ my $destroy_hit = 0; package Bar; use base qw(Class::Modular); - use constant METHODS => 'bleh'; sub bleh { return 1; @@ -58,7 +60,7 @@ my $foo = new Foo(qw(bar baz)); ok(defined $foo and UNIVERSAL::isa($foo,'Class::Modular'), 'new() works'); # 2: test load() -ok(exists $foo->{__class_modular}{_subclasses}{Foo}, 'load() works'); +ok($foo->is_loaded('Foo'), 'load and is_loaded work'); # 3: test AUTOLOAD ok($foo->blah, 'AUTOLOAD works'); @@ -86,3 +88,7 @@ eval {my $bar = new Bar(); undef $bar; }; ok($@ eq '','Non existant _destroy not a problem'); + +# Check _methods way of defining methods +my $bar = new Bar; +ok($bar->bleh, '_methods function works to define methods');