1#!/usr/bin/perl -w
2
3# Test _is_of_type()
4
5BEGIN {
6    chdir 't' if -d 't';
7}
8
9use lib './lib';
10use strict;
11use warnings;
12use ExtUtils::MakeMaker;
13
14use Test::More "no_plan";
15
16my $is_of_type = \&ExtUtils::MakeMaker::_is_of_type;
17
18my @tests = (
19    [23,                "",     1],
20    [[],                "",     0],
21    [{},                "",     0],
22    [[],                "HASH", 0],
23    [{},                "HASH", 1],
24    [bless({}, "Foo"),  "Foo",  1],
25    [bless({}, "Bar"),  "Foo",  0],
26    [bless([], "Foo"),  "",     0],
27    [bless([], "Foo"),  "HASH", 0],
28    [bless([], "Foo"),  "ARRAY", 1],
29);
30
31for my $test (@tests) {
32    my($thing, $type, $want) = @$test;
33
34    # [rt.cpan.org 41060]
35    local $SIG{__DIE__} = sub { fail("sigdie should be ignored") };
36    is !!$is_of_type->($thing, $type), !!$want, qq[_is_of_type($thing, '$type'): $want];
37}
38