package TE; use strict; require Exporter; use vars qw(@ISA @EXPORT); @ISA = qw(Exporter); @EXPORT = qw(exit exits_ok); use Test::Builder; my $Test = Test::Builder->new(); sub exit { my ($arg) = @_; $arg = '' if not defined $arg; die "EXIT$arg\n"; } sub exits_ok (&$;$$) { my ($coderef, $expecting, $description) = @_; $expecting = '' if not defined $expecting; $description ||= "exit $expecting"; my $result; eval {&$coderef}; my $ex = $@; $Test->ok($ex and $ex eq "EXIT$expecting\n", $description); if ($ex) { if ($ex =~ /^EXIT(.*)/) { if ($1 ne $expecting) { $Test->diag("Received '$1' expected '$expecting'"); } } else { $Test->diag("died before reaching an exit statement"); } } } 1;