diff options
author | Tony Cook <tony@develop-help.com> | 2019-08-29 11:24:35 +1000 |
---|---|---|
committer | Tony Cook <tony@develop-help.com> | 2019-11-25 15:04:54 +1100 |
commit | b596a3196ae74e66bb3100afa5b32d8d7b99f169 (patch) | |
tree | 5d3c4f0ffe4805a82776a2d7f2a9432e2a8fd6da /dist/Filter-Simple | |
parent | 7ab7fad021628a08252a364d99c0e4527ab26640 (diff) | |
download | perl-b596a3196ae74e66bb3100afa5b32d8d7b99f169.tar.gz |
Filter::Simple: fix and sanity check for executable_no_comments
fixes #17122
Diffstat (limited to 'dist/Filter-Simple')
-rw-r--r-- | dist/Filter-Simple/lib/Filter/Simple.pm | 3 | ||||
-rw-r--r-- | dist/Filter-Simple/t/filter_only.t | 19 | ||||
-rw-r--r-- | dist/Filter-Simple/t/lib/Filter/Simple/ExeNoComments.pm | 11 |
3 files changed, 31 insertions, 2 deletions
diff --git a/dist/Filter-Simple/lib/Filter/Simple.pm b/dist/Filter-Simple/lib/Filter/Simple.pm index 1dcf3c80bf..924c2aecbd 100644 --- a/dist/Filter-Simple/lib/Filter/Simple.pm +++ b/dist/Filter-Simple/lib/Filter/Simple.pm @@ -2,7 +2,7 @@ package Filter::Simple; use Text::Balanced ':ALL'; -our $VERSION = '0.95'; +our $VERSION = '0.96'; use Filter::Util::Call; use Carp; @@ -70,6 +70,7 @@ my %extractor_for = ( my %selector_for = ( all => sub { my ($t)=@_; sub{ $_=$$_; $t->(@_); $_} }, executable=> sub { my ($t)=@_; sub{ref() ? $_=$$_ : $t->(@_); $_} }, + executable_no_comments=> sub { my ($t)=@_; sub{ref() ? $_=$$_ : $t->(@_); $_} }, quotelike => sub { my ($t)=@_; sub{ref() && do{$_=$$_; $t->(@_)}; $_} }, regex => sub { my ($t)=@_; sub{ref() or return $_; diff --git a/dist/Filter-Simple/t/filter_only.t b/dist/Filter-Simple/t/filter_only.t index 57f108677e..cd86707efc 100644 --- a/dist/Filter-Simple/t/filter_only.t +++ b/dist/Filter-Simple/t/filter_only.t @@ -4,7 +4,7 @@ BEGIN { use Filter::Simple::FilterOnlyTest qr/not ok/ => "ok", "bad" => "ok", fail => "die"; -print "1..9\n"; +print "1..11\n"; sub fail { print "ok ", $_[0], "\n" } sub ok { print "ok ", $_[0], "\n" } @@ -41,3 +41,20 @@ print "ok 8\n"; print "not " unless "bad" =~ /bad/; print "ok 9\n"; + +use Filter::Simple::ExeNoComments; + +=for us + +shromplex + +=cut + +# shromplex + +# test the difference from code* +my $x = "ABC"; + +print $x eq "TEST" ? "" : "not ", "ok 10 # check strings processed\n"; + +print "ok 11 # executable_no_comments\n"; diff --git a/dist/Filter-Simple/t/lib/Filter/Simple/ExeNoComments.pm b/dist/Filter-Simple/t/lib/Filter/Simple/ExeNoComments.pm new file mode 100644 index 0000000000..3eaa45451f --- /dev/null +++ b/dist/Filter-Simple/t/lib/Filter/Simple/ExeNoComments.pm @@ -0,0 +1,11 @@ +package Filter::Simple::ExeNoComments; + +use Filter::Simple; + +FILTER_ONLY + executable_no_comments => sub { + $_ =~ /shromplex/ and die "We wants no shromplexes!"; + s/ABC/TEST/g; + }; + +1; |