is_of_type.t revision 1.1.1.1
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 ExtUtils::MakeMaker;
12
13use Test::More "no_plan";
14
15my $is_of_type = \&ExtUtils::MakeMaker::_is_of_type;
16
17my @tests = (
18    [23,                "",     1],
19    [[],                "",     0],
20    [{},                "",     0],
21    [[],                "HASH", 0],
22    [{},                "HASH", 1],
23    [bless({}, "Foo"),  "Foo",  1],
24    [bless({}, "Bar"),  "Foo",  0],
25    [bless([], "Foo"),  "",     0],
26    [bless([], "Foo"),  "HASH", 0],
27    [bless([], "Foo"),  "ARRAY", 1],
28);
29
30for my $test (@tests) {
31    my($thing, $type, $want) = @$test;
32
33    # [rt.cpan.org 41060]
34    local $SIG{__DIE__} = sub { fail("sigdie should be ignored") };
35    is !!$is_of_type->($thing, $type), !!$want, qq[_is_of_type($thing, '$type'): $want];
36}
37