From: Mark Fowler Date: Fri, 5 Jul 2013 18:42:56 +0000 (-0400) Subject: tests for naming X-Git-Tag: Try-Tiny-0.15~5 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d5cd0736e7971d29e11311b681f02b702b9f90fd;p=p5sagit%2FTry-Tiny.git tests for naming --- diff --git a/t/named.t b/t/named.t new file mode 100644 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 +