summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2013-07-22 20:52:17 -0400
committerJesse Luehrs <doy@tozt.net>2013-07-22 20:52:17 -0400
commitb180d098f917be6835e10bcb6fe72f3907306570 (patch)
tree3d160625871fbcdc091706c96e3c121c2d6705f9
parentb5b19c5f6a9f7548feffeed47f4d483b81b4d5bc (diff)
downloadparse-keyword-b180d098f917be6835e10bcb6fe72f3907306570.tar.gz
parse-keyword-b180d098f917be6835e10bcb6fe72f3907306570.zip
note that lexical subs don't work (fixes #2)
-rw-r--r--lib/Parse/Keyword.pm4
-rw-r--r--t/lexical.t35
2 files changed, 39 insertions, 0 deletions
diff --git a/lib/Parse/Keyword.pm b/lib/Parse/Keyword.pm
index 7047482..3f93523 100644
--- a/lib/Parse/Keyword.pm
+++ b/lib/Parse/Keyword.pm
@@ -174,6 +174,10 @@ This module also inherits the limitation from L<Devel::CallParser> that custom
parsing is only triggered if the keyword is called by its unqualified name
(C<try>, not C<Try::try>, for instance).
+This module doesn't yet work with lexical subs, such as via
+L<Exporter::Lexical>. This will hopefully be fixed in the future, but will
+likely require modifications to perl.
+
Please report any bugs to GitHub Issues at
L<https://github.com/doy/parse-keyword/issues>.
diff --git a/t/lexical.t b/t/lexical.t
new file mode 100644
index 0000000..15ba1d2
--- /dev/null
+++ b/t/lexical.t
@@ -0,0 +1,35 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use Test::More;
+
+BEGIN {
+ if (!eval { require Exporter::Lexical }) {
+ plan skip_all => "This test requires Exporter::Lexical";
+ }
+}
+
+BEGIN { plan skip_all => "This doesn't work yet." }
+
+BEGIN {
+ package My::Parser;
+ use Exporter::Lexical -exports => ['foo'];
+ use Parse::Keyword { foo => \&parse_foo };
+
+ sub foo { $_[0]->() }
+ sub parse_foo {
+ lex_read_space;
+ my $code = parse_block;
+ return sub { $code };
+ }
+ $INC{'My/Parser.pm'} = __FILE__;
+}
+
+{
+ use My::Parser;
+ is(foo { my $x = 1; $x + 3 }, 4);
+}
+eval "foo { 1 }";
+like $@, qr/slkfdj/;
+
+done_testing;