From: Graham Knop Date: Fri, 14 Oct 2016 23:36:06 +0000 (-0400) Subject: test for renaming lexical subs X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=295f376be8d5653d29ac45c5912e70f9ca8211a3;p=p5sagit%2FSub-Name.git test for renaming lexical subs --- diff --git a/t/lexical.t b/t/lexical.t new file mode 100644 index 0000000..97a3263 --- /dev/null +++ b/t/lexical.t @@ -0,0 +1,31 @@ +use strict; +use warnings; + +use Test::More; +BEGIN { + if ("$]" < 5.018) { + plan 'skip_all' => 'lexical subs not supported on this perl'; + } +} + +use feature 'lexical_subs'; +no warnings 'experimental::lexical_subs'; + +use Sub::Name; + +local $TODO = "lexical subs unnameable until perl 5.22" + unless "$]" >= 5.022; + +my $foo = sub { (caller 0)[3] }; + +my sub foo { (caller 0)[3] } + +subname 'main::foo2' => \&foo; +is foo(), 'main::foo2', 'lexical subs can be named'; + +my $x = 3; +my sub bar { (caller 0)[$x] } +subname 'main::bar2' => \&bar; +is bar(), 'main::bar2', 'lexical closure subs can be named'; + +done_testing;