File: 11isa.t

package info (click to toggle)
libtype-tiny-xs-perl 0.022-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 480 kB
  • sloc: perl: 158; ansic: 157; pascal: 33; makefile: 3; sh: 1
file content (26 lines) | stat: -rw-r--r-- 434 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
use strict;
use warnings;
use Test::More;

{
	package MockFoo;
	sub isa {
		return 1 if $_[1] eq 'Foo';
		shift->isa( @_ );
	}
}

{
	package FooChild;
	our @ISA = qw( Foo );
}

use Type::Tiny::XS;
my $check = Type::Tiny::XS::get_coderef_for('InstanceOf[Foo]');

ok(   $check->( bless [], "Foo" ) );
ok(   $check->( bless [], "MockFoo" ) );
ok(   $check->( bless [], "FooChild" ) );
ok( ! $check->( bless [], "Bar" ) );

done_testing;