summaryrefslogtreecommitdiff
path: root/t/lib/TestUtils.pm
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2015-01-31 02:13:12 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2015-01-31 02:13:12 +0000
commit7446bb2b9d24fa6b702fbb62d73084a32ade6f75 (patch)
tree50037edde1d3cde3aaa25e759cd39975841ca663 /t/lib/TestUtils.pm
downloadClass-Tiny-tarball-7446bb2b9d24fa6b702fbb62d73084a32ade6f75.tar.gz
Diffstat (limited to 't/lib/TestUtils.pm')
-rw-r--r--t/lib/TestUtils.pm28
1 files changed, 28 insertions, 0 deletions
diff --git a/t/lib/TestUtils.pm b/t/lib/TestUtils.pm
new file mode 100644
index 0000000..c66b8b3
--- /dev/null
+++ b/t/lib/TestUtils.pm
@@ -0,0 +1,28 @@
+use 5.006;
+use strict;
+use warnings;
+package TestUtils;
+
+use Carp;
+
+use Exporter;
+our @ISA = qw/Exporter/;
+our @EXPORT = qw(
+ exception
+);
+
+# If we have Test::FailWarnings, use it
+BEGIN {
+ eval { require Test::FailWarnings; 1 } and do { Test::FailWarnings->import };
+}
+
+sub exception(&) {
+ my $code = shift;
+ my $success = eval { $code->(); 1 };
+ my $err = $@;
+ return '' if $success;
+ croak "Execution died, but the error was lost" unless $@;
+ return $@;
+}
+
+1;