From 40ecb271cd82f320753f4593b8e902b1a6a4b2ed Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Mon, 22 Jul 2013 19:43:51 -0400 Subject: allow creating non-anonymous subs too this makes a difference in some obscure cases dealing with closures. see t/unavailable.t for more information. --- t/unavailable.t | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 t/unavailable.t (limited to 't') diff --git a/t/unavailable.t b/t/unavailable.t new file mode 100644 index 0000000..06db914 --- /dev/null +++ b/t/unavailable.t @@ -0,0 +1,48 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More; + +BEGIN { + package My::Parser; + use Exporter 'import'; + our @EXPORT = ('foo', 'bar'); + + use Parse::Keyword { + foo => \&parse_foo, + bar => \&parse_bar, + }; + + sub foo {} + + sub parse_foo { + lex_read_space; + die unless lex_peek eq '{'; + parse_block(1)->(); + return (sub {}, 1); + } + + sub bar { $::body = $_[0] } + + sub parse_bar { + lex_read_space; + die unless lex_peek eq '{'; + my $body = parse_block; + return (sub { $body }, 1); + } + + $INC{'My/Parser.pm'} = __FILE__; +} + +use My::Parser; + +my $bar; +my $baz = 5; + +foo { + bar { $baz } +} + +is($::body->(), 5); + +done_testing; -- cgit v1.2.3-54-g00ecf