tests for naming
Mark Fowler [Fri, 5 Jul 2013 18:42:56 +0000 (14:42 -0400)]
t/named.t [new file with mode: 0644]

diff --git a/t/named.t b/t/named.t
new file mode 100644 (file)
index 0000000..d8a4d95
--- /dev/null
+++ b/t/named.t
@@ -0,0 +1,28 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More;
+
+BEGIN {
+       plan skip_all => "Sub::Name required"
+               unless eval { require Sub::Name; 1 };
+       plan tests => 3;
+}
+
+BEGIN { use_ok 'Try::Tiny' }
+
+my $name;
+try {
+       $name = (caller(0))[3];
+};
+is $name, "main::try {...}", "try name";
+
+try {
+       die "Boom";
+} catch {
+       $name = (caller(0))[3]; 
+};
+is $name, "main::catch {...} ", "catch name"; # note extra space
+