summaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2013-07-22 19:43:51 -0400
committerJesse Luehrs <doy@tozt.net>2013-07-22 19:48:11 -0400
commit40ecb271cd82f320753f4593b8e902b1a6a4b2ed (patch)
tree63f93194d54bd08b47fbffec5adfb988d0a35d31 /t
parent2888936658f395416cb183aa8a5f24e6e3ea585c (diff)
downloadparse-keyword-40ecb271cd82f320753f4593b8e902b1a6a4b2ed.tar.gz
parse-keyword-40ecb271cd82f320753f4593b8e902b1a6a4b2ed.zip
allow creating non-anonymous subs too
this makes a difference in some obscure cases dealing with closures. see t/unavailable.t for more information.
Diffstat (limited to 't')
-rw-r--r--t/unavailable.t48
1 files changed, 48 insertions, 0 deletions
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;