X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F11-call-perl.t;fp=t%2F11-call-perl.t;h=d600d321047c40360114d7a93f5d68d224f37abd;hb=7eb360aa8aa4a3fbd88d6bf1dedd601e6dcef62e;hp=0000000000000000000000000000000000000000;hpb=3873fbc39d250734131e096da47add0cf601d194;p=perl%2Fmodules%2Fre-engine-Hooks.git diff --git a/t/11-call-perl.t b/t/11-call-perl.t new file mode 100644 index 0000000..d600d32 --- /dev/null +++ b/t/11-call-perl.t @@ -0,0 +1,50 @@ +#!perl -T + +use strict; +use warnings; + +use blib 't/re-engine-Hooks-TestDist'; + +use Test::More tests => 2 * 2; + +# Those tests must be ran inside eval STRING because the test distribution +# can hold only one callback at a time. + +my @nodes; + +eval <<'TEST1'; +my $rx = do { + use re::engine::Hooks::TestDist 'custom' => sub { push @nodes, @_ }; + qr/.(?:a|o).*/; +}; + +{ + local $@; + eval { + "foo" =~ $rx; + }; + is $@, '', 'calling perl code in the exec hook does not croak'; + is_deeply \@nodes, [ qw ], + 'calling perl code in the exec hook works correctly'; +} +TEST1 +die $@ if $@; + +eval <<'TEST2'; +my $res; + +my $rx = do { + use re::engine::Hooks::TestDist 'custom' => sub { $res += ("durp" =~ /.urp/) }; + qr/.(?:a|o).*/; +}; + +{ + local $@; + eval { + "foo" =~ $rx; + }; + is $@, '', 'a regexp match in the exec hook does not croak'; + is $res, scalar(@nodes), 'a regexp match in the exec hook works correctly'; +} +TEST2 +die $@ if $@;