File: named.t

package info (click to toggle)
libtry-tiny-perl 0.20-1~bpo70%2B1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy-backports
  • size: 188 kB
  • sloc: perl: 494; makefile: 2
file content (37 lines) | stat: -rw-r--r-- 561 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/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;
}

use Try::Tiny;

my $name;
try {
	$name = (caller(0))[3];
};
is $name, "main::try {...} ", "try name"; # note extra space

try {
	die "Boom";
} catch {
	$name = (caller(0))[3];
};
is $name, "main::catch {...} ", "catch name"; # note extra space

try {
	die "Boom";
} catch {
	# noop
} finally {
	$name = (caller(0))[3];
};
is $name, "main::finally {...} ", "finally name"; # note extra space