Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Test-Base CPAN distribution.

Report information
The Basics
Id: 17276
Status: open
Priority: 0/
Queue: Test-Base

People
Owner: Nobody in particular
Requestors:
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: filter functions don't seem to work
use t::Test; plan tests => 1 * blocks; run_is input => 'expected'; sub my_len { return scalar(@_); } __END__ === Test one --- input lines my_len foo bar baz --- expected eval 3 1..1 not ok 1 - Test one # Failed test 'Test one' # in t/molset.t at line 3. # got: 'foo # bar # baz # ' # expected: '3' # Looks like you failed 1 test of 1.
Subject: Re: [rt.cpan.org #17276] filter functions don't seem to work
Date: Fri, 27 Jan 2006 10:46:09 -0800
To: Guest via RT <bug-Test-Base [...] rt.cpan.org>
From: ingy [...] ttul.org (Ingy dot Net)
Filters in the main namespace act a little differently when you return a number. If a number or undef is returned the result is taken from $_. That way you can write s// substitutions as filters: sub filter1 { s/foo/bar/; } In your case use: sub my_len { $_ = scalar(@_); } The other solution is to put the filter in t::Test, under the t::Test::Filter namespace: package t::Test::Filter; sub my_len { return scalar(@_); } Hope that helps, Ingy On 25/01/06 11:19 -0500, Guest via RT wrote: Show quoted text
> > Wed Jan 25 11:19:35 2006: Request 17276 was acted upon. > Transaction: Ticket created by guest > Queue: Test-Base > Subject: filter functions don't seem to work > Owner: Nobody > Requestors: > Status: new > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=17276 > > > > use t::Test; > plan tests => 1 * blocks; > run_is input => 'expected'; > > > > sub my_len { > return scalar(@_); > } > > > > __END__ > > > > === Test one > --- input lines my_len > foo > bar > baz > > > > --- expected eval > 3 > > > > 1..1 > not ok 1 - Test one > # Failed test 'Test one' > # in t/molset.t at line 3. > # got: 'foo > # bar > # baz > # ' > # expected: '3' > # Looks like you failed 1 test of 1. > > > > > > >
Thanks for that, and thanks for Test::Base --- it is the least painful test framework I have found yet ;) Regards, Ben On Fri Jan 27 13:35:46 2006, ingy@ttul.org wrote: Show quoted text
> Filters in the main namespace act a little differently when you return > a > number. If a number or undef is returned the result is taken from $_. > > That way you can write s// substitutions as filters: > > sub filter1 { > s/foo/bar/; > } > > In your case use: > > sub my_len { > $_ = scalar(@_); > } > > The other solution is to put the filter in t::Test, under the > t::Test::Filter > namespace: > > package t::Test::Filter; > > sub my_len { > return scalar(@_); > } > > Hope that helps, Ingy > > On 25/01/06 11:19 -0500, Guest via RT wrote:
> > > > Wed Jan 25 11:19:35 2006: Request 17276 was acted upon. > > Transaction: Ticket created by guest > > Queue: Test-Base > > Subject: filter functions don't seem to work > > Owner: Nobody > > Requestors: > > Status: new > > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=17276 > > > > > > > use t::Test; > > plan tests => 1 * blocks; > > run_is input => 'expected'; > > > > > > > > sub my_len { > > return scalar(@_); > > } > > > > > > > > __END__ > > > > > > > > === Test one > > --- input lines my_len > > foo > > bar > > baz > > > > > > > > --- expected eval > > 3 > > > > > > > > 1..1 > > not ok 1 - Test one > > # Failed test 'Test one' > > # in t/molset.t at line 3. > > # got: 'foo > > # bar > > # baz > > # ' > > # expected: '3' > > # Looks like you failed 1 test of 1. > > > > > > > > > > > > > >
Subject: Re: [rt.cpan.org #17276] filter functions don't seem to work
Date: Mon, 30 Jan 2006 17:22:16 -0800
To: Guest via RT <bug-Test-Base [...] rt.cpan.org>
From: ingy [...] ttul.org (Ingy dot Net)
On 30/01/06 08:29 -0500, Guest via RT wrote: Show quoted text
> > <URL: http://rt.cpan.org/Ticket/Display.html?id=17276 > > > Thanks for that, and thanks for Test::Base --- it is the least painful > test framework I have found yet ;)
Thanks. FYI, Check out how the latest YAML distro uses use_test_base; in Makefile.PL to autobundle Test-Base. So easy. Now Test-Base isn't an extra prerequisite! Cheers, Ingy Show quoted text
> > Regards, > > Ben > > On Fri Jan 27 13:35:46 2006, ingy@ttul.org wrote:
> > Filters in the main namespace act a little differently when you return > > a > > number. If a number or undef is returned the result is taken from $_. > > > > That way you can write s// substitutions as filters: > > > > sub filter1 { > > s/foo/bar/; > > } > > > > In your case use: > > > > sub my_len { > > $_ = scalar(@_); > > } > > > > The other solution is to put the filter in t::Test, under the > > t::Test::Filter > > namespace: > > > > package t::Test::Filter; > > > > sub my_len { > > return scalar(@_); > > } > > > > Hope that helps, Ingy > > > > On 25/01/06 11:19 -0500, Guest via RT wrote:
> > > > > > Wed Jan 25 11:19:35 2006: Request 17276 was acted upon. > > > Transaction: Ticket created by guest > > > Queue: Test-Base > > > Subject: filter functions don't seem to work > > > Owner: Nobody > > > Requestors: > > > Status: new > > > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=17276 > > > > > > > > > > use t::Test; > > > plan tests => 1 * blocks; > > > run_is input => 'expected'; > > > > > > > > > > > > sub my_len { > > > return scalar(@_); > > > } > > > > > > > > > > > > __END__ > > > > > > > > > > > > === Test one > > > --- input lines my_len > > > foo > > > bar > > > baz > > > > > > > > > > > > --- expected eval > > > 3 > > > > > > > > > > > > 1..1 > > > not ok 1 - Test one > > > # Failed test 'Test one' > > > # in t/molset.t at line 3. > > > # got: 'foo > > > # bar > > > # baz > > > # ' > > > # expected: '3' > > > # Looks like you failed 1 test of 1. > > > > > > > > > > > > > > > > > > > > >
> >