Commit | Line | Data |
c0956255 |
1 | #!/usr/bin/perl -w |
2 | |
3 | # Test _is_of_type() |
4 | |
d00e3d8a |
5 | BEGIN { |
6 | chdir 't' if -d 't'; |
d00e3d8a |
7 | } |
8 | |
9 | use lib './lib'; |
c0956255 |
10 | use strict; |
11 | use ExtUtils::MakeMaker; |
12 | |
13 | use Test::More "no_plan"; |
14 | |
15 | my $is_of_type = \&ExtUtils::MakeMaker::_is_of_type; |
16 | |
17 | my @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 | |
30 | for 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 | } |