summaryrefslogtreecommitdiff
path: root/t/10throw-in-catch.t
diff options
context:
space:
mode:
Diffstat (limited to 't/10throw-in-catch.t')
-rw-r--r--t/10throw-in-catch.t41
1 files changed, 41 insertions, 0 deletions
diff --git a/t/10throw-in-catch.t b/t/10throw-in-catch.t
new file mode 100644
index 0000000..7d2af3e
--- /dev/null
+++ b/t/10throw-in-catch.t
@@ -0,0 +1,41 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Error qw(:try);
+use Test::More tests => 2;
+
+my ($error);
+
+eval
+{
+try {
+ throw Error::Simple( "message" );
+}
+catch Error::Simple with {
+ die "A-Lovely-Day";
+};
+};
+$error = $@;
+
+# TEST
+ok (scalar($error =~ /^A-Lovely-Day/),
+ "Error thrown in the catch clause is registered"
+);
+
+eval {
+try {
+ throw Error::Simple( "message" );
+}
+otherwise {
+ die "Had-the-ancient-greeks";
+};
+};
+$error = $@;
+
+# TEST
+ok (scalar($error =~ /^Had-the-ancient/),
+ "Error thrown in the otherwise clause is registered"
+);
+