This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Move ExtUtils::CBuilder from lib to ext.
[perl5.git] / lib / ExtUtils / t / is_of_type.t
1 #!/usr/bin/perl -w
2
3 # Test _is_of_type()
4
5 BEGIN {
6     chdir 't' if -d 't';
7
8     if( $ENV{PERL_CORE} ) {
9         @INC = '../lib';
10     }
11 }
12
13 use lib './lib';
14 use strict;
15 use ExtUtils::MakeMaker;
16
17 use Test::More "no_plan";
18
19 my $is_of_type = \&ExtUtils::MakeMaker::_is_of_type;
20
21 my @tests = (
22     [23,                "",     1],
23     [[],                "",     0],
24     [{},                "",     0],
25     [[],                "HASH", 0],
26     [{},                "HASH", 1],
27     [bless({}, "Foo"),  "Foo",  1],
28     [bless({}, "Bar"),  "Foo",  0],
29     [bless([], "Foo"),  "",     0],
30     [bless([], "Foo"),  "HASH", 0],
31     [bless([], "Foo"),  "ARRAY", 1],
32 );
33
34 for my $test (@tests) {
35     my($thing, $type, $want) = @$test;
36
37     # [rt.cpan.org 41060]
38     local $SIG{__DIE__} = sub { fail("sigdie should be ignored") };
39     is !!$is_of_type->($thing, $type), !!$want, qq[_is_of_type($thing, '$type'): $want];
40 }