X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2Fcallbacks%2Fexec.t;fp=t%2Fcallbacks%2Fexec.t;h=d340ffe54d6b6147e26f34bd0b3b93b23004ecd7;hb=bc365867d2883a69972ef82adf4b19d0680e43aa;hp=0000000000000000000000000000000000000000;hpb=18ec04e7558b13fcd57575f566794a909ca60aca;p=perl%2Fmodules%2Fre-engine-Plugin.git diff --git a/t/callbacks/exec.t b/t/callbacks/exec.t new file mode 100644 index 0000000..d340ffe --- /dev/null +++ b/t/callbacks/exec.t @@ -0,0 +1,38 @@ +#!perl + +use strict; +use warnings; + +use Test::More tests => 4 * 2; + +my $count; + +use re::engine::Plugin comp => sub { + my ($re) = @_; + + my $pat = $re->pattern; + + $re->callbacks( + exec => sub { + my ($re, $str) = @_; + + ++$count; + + return $str eq $pat; + }, + ); +}; + +$count = 0; + +ok "foo" =~ /foo/; +is $count, 1; +ok "fool" !~ /foo/; +is $count, 2; + +my $rx = qr/bar/; + +ok "bar" =~ $rx; +is $count, 3; +ok "foo" !~ $rx; +is $count, 4;