- or download this
use Test::More 'tests' => 5;
...
ok( ! is_code( $undef ), 'undef is not code' );
ok( ! is_code( 'string' ), 'string is not code' );
ok( is_code( 'real_sub' ), 'string is code' );
- or download this
sub is_code {
no warnings qw( void uninitialized );
return '' ne ref $_[0] && eval { defined &{$_[0]} };
}
- or download this
use strict;
use warnings;
...
ok( ! $side_effect, "$name: no side effect" );
is( $undef, undef, "$name: \$undef is still undef" );
}