Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Test::Base::Filter woes

by nglenn (Beadle)
on Sep 21, 2012 at 16:28 UTC ( [id://994940]=perlquestion: print w/replies, xml ) Need Help??

nglenn has asked for the wisdom of the Perl Monks concerning the following question:

I am seeing some unexpected behavior in my Test::Base::Filters. Here is an expample for duplication: In MyTest.pm:
package t::MyTest; use Test::Base -Base; #some stuff here package t::MyTest::Filter; use base 'Test::Base::Filter'; sub choose { print @_; return {foo => 'bar'} if($_[0] eq '1'); return undef; } sub is_defined{ print @_; defined $_[0]; }
And in test.t:
use t::MyTest; filters {input => [qw(choose is_defined)] }; __END__ === First --- input 1 --- expected: 1 === Second --- input 0 --- expected: 0
What I expect is for the two filters to chain, the output of parse becoming the input to is_defined. Place both of the files in in a "t" folder and run "prove -v", and this is the output:
t\01-test.t .. Use of uninitialized value $_[1] in print at t/MyTest.p +m line 14, <DATA> line 1. 1 t::MyTest::Filter=HASH(0x2af1670)ok 1 - First 1..1 Failed 1/1 subtests Test Summary Report ------------------- t\01-test.t (Wstat: 0 Tests: 0 Failed: 0) Parse errors: Bad plan. You planned 1 tests but ran 0. Files=1, Tests=0, 1 wallclock secs ( 0.06 usr + 0.23 sys = 0.30 CPU +) Result: FAIL
Nevermind the warning, which I don't understand the root of. Why is the input to the first filter the actual input, and the input to the second filter some filter object? I'm also uncertain why only one test was run, instead of the two I expected.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://994940]
Front-paged by Arunbear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2024-04-23 10:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found