diff options
author | Jesse Luehrs <doy@tozt.net> | 2013-07-23 18:56:20 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2013-07-23 18:56:20 -0400 |
commit | 60b8b4ddf6ce5280991a87fe3947aa769bf9cb8b (patch) | |
tree | ee567c74cf1bcef7d44490f1204135e0ddb18f24 | |
parent | ec07fc746048ae4e894e7cb327938ccfe3eb7644 (diff) | |
download | parse-keyword-60b8b4ddf6ce5280991a87fe3947aa769bf9cb8b.tar.gz parse-keyword-60b8b4ddf6ce5280991a87fe3947aa769bf9cb8b.zip |
pass the keyword name to parser functions
-rw-r--r-- | Keyword.xs | 2 | ||||
-rw-r--r-- | t/keyword-name.t | 25 |
2 files changed, 27 insertions, 0 deletions
@@ -65,6 +65,8 @@ static OP *parser_callback(pTHX_ GV *namegv, SV *psobj, U32 *flagsp) */ PUSHMARK(SP); + mXPUSHp(GvNAME(namegv), GvNAMELEN(namegv)); + PUTBACK; count = call_sv(psobj, G_ARRAY); SPAGAIN; if (count > 1) { diff --git a/t/keyword-name.t b/t/keyword-name.t new file mode 100644 index 0000000..8ab2f44 --- /dev/null +++ b/t/keyword-name.t @@ -0,0 +1,25 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More; + +BEGIN { + package My::Parser; + use Exporter 'import'; + our @EXPORT = 'foo'; + + use Parse::Keyword { foo => \&parse_foo }; + + sub foo { $_[0] } + sub parse_foo { + my ($keyword) = @_; + return sub { uc($keyword) }; + } + + $INC{'My/Parser.pm'} = __FILE__; +} + +use My::Parser; +is(foo, 'FOO'); + +done_testing; |