18_register_argument_checking.t 1.05 KB
Newer Older
1
use strict;
2
use lib ".";
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
local $^W = 1;
use Test::More;

# keep stdout and stderr in order on Win32

BEGIN {
    $|=1; 
    my $oldfh = select(STDERR); $| = 1; select($oldfh);
}

#--------------------------------------------------------------------------#
# option() argument cases
#--------------------------------------------------------------------------#

my @cases = (
    {
        label   => q{invalid call to register: no argument},
        args    => q{},
        error   => q{empty argument list},
    },
    {
        label   => q{invalid register argument: reference with no class name},
        args    => q{ {} },
        error   => q{must be an object or class name},
    },
);

#--------------------------------------------------------------------------#
# Begin tests
#--------------------------------------------------------------------------#

plan tests => 1 + @cases;

require_ok( "Class::InsideOut" );

for my $case ( @cases ) {
    eval( "Class::InsideOut::register( " . $case->{args} . ")" );
    like( $@, "/$case->{error}/i", "$case->{label}");
}