Created
March 29, 2010 09:44
-
-
Save walf443/347660 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Foo; | |
sub new { | |
bless {}, shift; | |
} | |
sub call_foo { | |
my $self = shift; | |
return __PACKAGE__; | |
} | |
package Bar; | |
use base qw(Foo); | |
sub call_bar { | |
my $self = shift; | |
return ref $self; | |
} | |
package Hoge; | |
sub new { | |
bless {}, __PACKAGE__; | |
} | |
sub shared_method { | |
return "Hoge"; | |
} | |
package Fuga; | |
use base qw(Hoge); | |
sub fuga_only_metohd { | |
return "called!!"; | |
} | |
sub shared_method { | |
return "Fuga"; | |
} | |
package main; | |
use strict; | |
use warnings; | |
use Test::More; | |
my $bar = Bar->new; | |
is($bar->call_foo, "Foo", "__PACKAGE__はひきづがれないこと"); | |
is($bar->call_bar, "Bar", 'ref $selfは変わること'); | |
my $fuga = Fuga->new; | |
is(ref $fuga, "Hoge", "__PACKAGE__のままになっちゃうこと"); | |
is(ref $fuga, "Fuga", "ほんとはこうなってほしいけど、このテストは失敗する"); | |
can_ok($fuga, "fuga_only_metohd", "fuga_only_metohdが呼べてほしいけど、このテストは失敗する"); | |
is($fuga->shared_method, "Fuga", "Fugaになってほしいけど、このテストは失敗する"); | |
done_testing; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment