summaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2013-07-23 03:04:36 -0400
committerJesse Luehrs <doy@tozt.net>2013-07-23 03:04:36 -0400
commit9e4b587dca809519106f004df09f5aa01b721e9a (patch)
tree281670afec866e3838b8cc7f357dba2a1bf7daae /t
parent4be323863ef8e84d05d1f6dc74f0dff2e9fc0bb1 (diff)
downloadparse-keyword-9e4b587dca809519106f004df09f5aa01b721e9a.tar.gz
parse-keyword-9e4b587dca809519106f004df09f5aa01b721e9a.zip
don't return a coderef if there was a parse error
it won't be a valid coderef, you'll just get an error if you try to call it
Diffstat (limited to 't')
-rw-r--r--t/error.t33
1 files changed, 33 insertions, 0 deletions
diff --git a/t/error.t b/t/error.t
new file mode 100644
index 0000000..08a478a
--- /dev/null
+++ b/t/error.t
@@ -0,0 +1,33 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use Test::More;
+
+my $got_code;
+BEGIN {
+ package My::Parser;
+ use Exporter 'import';
+ our @EXPORT = 'foo';
+ use Parse::Keyword { foo => \&parse_foo };
+
+ sub foo {}
+ sub parse_foo {
+ lex_read_space;
+ my $code = parse_block;
+ $got_code = $code ? 1 : 0;
+ return sub {};
+ }
+
+ $INC{'My/Parser.pm'} = __FILE__;
+}
+
+use My::Parser;
+
+eval "foo";
+ok($@);
+ok(!$got_code);
+eval "foo { }";
+ok(!$@);
+ok($got_code);
+
+done_testing;