1#!perl -Tw 2 3use warnings; 4use strict; 5 6use Test::More tests => 5; 7use Carp::Assert::More; 8 9use IO::File; # just for creating objects 10 11local $@; 12$@ = ''; 13 14eval { 15 my $fh = new IO::File; 16 assert_isa( $fh, 'IO::File', 'Created an IO::File object' ); 17 assert_isa( $fh, 'GLOB', 'Created an IO::File object, which is a GLOB' ); 18}; 19is( $@, '' ); 20 21eval { # integer is not an object 22 my $random = 2112; 23 assert_isa( $random, 'IO::File', 'Created an IO::File object' ); 24}; 25like( $@, qr/Assertion.*failed/ ); 26 27eval { # undef is not an object 28 my $random = undef; 29 assert_isa( $random, 'IO::File', 'Created an IO::File object' ); 30}; 31like( $@, qr/Assertion.*failed/ ); 32 33 34eval { 35 my @array; 36 assert_isa( \@array, 'HASH', 'An array is not a hash' ); 37}; 38like( $@, qr/Assertion.*failed/ ); 39 40eval { 41 my %hash; 42 assert_isa( \%hash, 'HASH', 'Created a hash' ); 43}; 44is( $@, '' ); 45