#!perl # exception.t tests all of Exception. use strict; use warnings; use diagnostics; use 5.010; use Test::More;# tests => '19'; BEGIN { use_ok('Exception', 'create_exception'); } # Test uneven params. # create exception w/params create_exception('ParameterException', 'description', 'param', 'param2'); evalok(sub {eval {die Exception->throw('TestException', param =>)};}, < '1', b => '2', c => '3') EOD done_testing(); # runs code, and validates the $@ error message. # Why make people install Test::Exception if this little bit of code is all # that's needed? sub evalok { my ($code, $expected_message, $test_name) = @_; $code->(); my $croak = $@; $croak =~ s/\sat.*\n$//; #remove cruft. is($croak, $expected_message, $test_name); }