3 # Test isa_ok() and can_ok() in test.pl
8 BEGIN { require "test.pl"; }
12 can_ok('Test::More', qw(require_ok use_ok ok is isnt like skip can_ok
13 pass fail eq_array eq_hash eq_set));
14 can_ok(bless({}, "Test::More"), qw(require_ok use_ok ok is isnt like skip
15 can_ok pass fail eq_array eq_hash eq_set));
18 isa_ok(bless([], "Foo"), "Foo");
20 isa_ok(\42, 'SCALAR');
23 local @Foo::ISA = 'Bar';
24 isa_ok( "Foo", "Bar" );
28 # can_ok() & isa_ok should call can() & isa() on the given object, not
29 # just class, in case of custom can()
33 *Foo::can = sub { $_[0]->[0] };
34 *Foo::isa = sub { $_[0]->[0] };
35 my $foo = bless([0], 'Foo');
36 ok( ! $foo->can('bar') );
37 ok( ! $foo->isa('bar') );
39 can_ok( $foo, 'blah');
40 isa_ok( $foo, 'blah');
44 note "object/class_ok"; {
47 our @ISA = qw(Parent);
52 sub new { bless {}, shift }
55 # Unfortunately we can't usefully test the failure case without
56 # significantly modifying test.pl
57 class_ok "Child", "Parent";
58 class_ok "Parent", "Parent";
59 object_ok( Parent->new, "Parent" );
60 object_ok( Child->new, "Parent" );