tests for naming
[p5sagit/Try-Tiny.git] / t / named.t
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use Test::More;
7
8 BEGIN {
9         plan skip_all => "Sub::Name required"
10                 unless eval { require Sub::Name; 1 };
11         plan tests => 3;
12 }
13
14 BEGIN { use_ok 'Try::Tiny' }
15
16 my $name;
17 try {
18         $name = (caller(0))[3];
19 };
20 is $name, "main::try {...}", "try name";
21
22 try {
23         die "Boom";
24 } catch {
25         $name = (caller(0))[3]; 
26 };
27 is $name, "main::catch {...} ", "catch name"; # note extra space
28