summaryrefslogtreecommitdiff
path: root/t/12wrong-error-var.t
diff options
context:
space:
mode:
Diffstat (limited to 't/12wrong-error-var.t')
-rw-r--r--t/12wrong-error-var.t37
1 files changed, 37 insertions, 0 deletions
diff --git a/t/12wrong-error-var.t b/t/12wrong-error-var.t
new file mode 100644
index 0000000..888c723
--- /dev/null
+++ b/t/12wrong-error-var.t
@@ -0,0 +1,37 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More tests => 2;
+
+use Error qw(:try);
+
+try {
+ eval {
+ throw Error::Simple "This is caught by eval, not by try.";
+ };
+
+ # TEST
+ ok (($@ && $@ =~ /This is caught by eval, not by try/),
+ "Checking that eval { ... } is sane"
+ );
+
+ print "# Error::THROWN = $Error::THROWN\n";
+
+ die "This is a simple 'die' exception.";
+
+ # not reached
+}
+otherwise {
+ my $E = shift;
+ my $t = $Error::THROWN ? "$Error::THROWN" : '';
+ print "# Error::THROWN = $t\n";
+ $E ||= '';
+ print "# E = $E\n";
+
+ # TEST
+ ok ("$E" =~ /This is a simple 'die' exception/,
+ "Checking that the argument to otherwise is the thrown exception"
+ );
+};