1#! /usr/bin/perl -Tw 2 3use strict; 4use warnings; 5 6use Test::More tests => 5; 7 8BEGIN { use_ok( 'Test::Exception' ) }; 9 10sub div { 11 my ($a, $b) = @_; 12 return( $a / $b ); 13}; 14 15dies_ok { div(1, 0) } 'exception thrown okay in dies_ok'; 16like( $@, '/^Illegal division by zero/', 'exception preserved after dies_ok' ); 17 18throws_ok { div(1, 0) } '/^Illegal division by zero/', 'exception thrown okay in throws_ok'; 19like( $@, '/^Illegal division by zero/', 'exception preserved after thrown_ok' ); 20