diff options
Diffstat (limited to 't/11rethrow.t')
-rw-r--r-- | t/11rethrow.t | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/t/11rethrow.t b/t/11rethrow.t new file mode 100644 index 0000000..227bca5 --- /dev/null +++ b/t/11rethrow.t @@ -0,0 +1,50 @@ +#!/usr/bin/perl + +use Error qw(:try); +use Test::More tests => 4; + +try { + try { die "inner" } + catch Error::Simple with { die "foobar" }; +} +otherwise +{ + my $err = shift; + # TEST + ok (scalar($err =~ /foobar/), "Error rethrown"); +}; + +try { + try { die "inner" } + catch Error::Simple with { throw Error::Simple "foobar" }; +} +otherwise +{ + my $err = shift; + # TEST + ok (scalar("$err" =~ /foobar/), "Thrown Error::Simple"); +}; + +try { + try { die "inner" } + otherwise { die "foobar" }; +} +otherwise +{ + my $err = shift; + # TEST + ok (scalar("$err" =~ /foobar/), "die foobar"); +}; + +try { + try { die "inner" } + catch Error::Simple with { throw Error::Simple "foobar" }; +} +otherwise +{ + my $err = shift; + # TEST + ok (scalar($err =~ /foobar/), "throw Error::Simple"); +}; + +1; |