Re: Subtest fail with singletons

2009-06-29 Thread Ovid
- Original Message > From: Michael G Schwern > > Ovid wrote: > > > > I've generally been extremely pleased with how robust 'local > > $hash->{value}' > is, > > but you can't localize lexical variables. > > The Test::Builder singleton is now a package global. Given that I think I ma

Re: Subtest fail with singletons

2009-06-29 Thread Michael G Schwern
Ovid wrote: > - Original Message > >> From: Michael G Schwern >> %$Test = %$child; Watch out for edge cases of when subtest() dies, make sure the parent's guts get put back. >>> "local" should be good for doing that right? >> Normally, yes. local $Test will

Re: Subtest fail with singletons

2009-06-29 Thread Ovid
- Original Message > From: Michael G Schwern > > >> %$Test = %$child; > >> > >> Watch out for edge cases of when subtest() dies, make sure the > >> parent's guts > >> get put back. > > > > "local" should be good for doing that right? > > Normally, yes. local $Test will localize t

Re: Subtest fail with singletons

2009-06-29 Thread Michael G Schwern
Michael Peters wrote: > Michael G Schwern wrote: > >> A simple strategy might be to just replace the global singleton with the >> child's guts at the start of a subtest() and then back out again at >> the end. >> >> %$Test = %$child; >> >> Watch out for edge cases of when subtest() dies, make

Re: Subtest fail with singletons

2009-06-29 Thread Ovid
- Original Message > From: Michael G Schwern > > A simple strategy might be to just replace the global singleton with the > child's guts at the start of a subtest() and then back out again at the end. > > %$Test = %$child; I don't think that the child should ever have knowledge of

Re: Subtest fail with singletons

2009-06-29 Thread Michael Peters
Michael G Schwern wrote: A simple strategy might be to just replace the global singleton with the child's guts at the start of a subtest() and then back out again at the end. %$Test = %$child; Watch out for edge cases of when subtest() dies, make sure the parent's guts get put back. "loc

Re: Subtest fail with singletons

2009-06-29 Thread Michael G Schwern
Ovid wrote: > - Original Message > >> From: David E. Wheeler >> To: Ovid >> Cc: perl-qa@perl.org >> Sent: Monday, 29 June, 2009 17:38:15 >> Subject: Re: Subtest fail with singletons >> >> On Jun 29, 2009, at 2:19 AM, Ovid wrote: >>

Re: Subtest fail with singletons

2009-06-29 Thread Ovid
- Original Message > From: David E. Wheeler > > > And Test::Exception and many, many other Test:: modules. It's a very > > common > pattern and getting all authors to agree to fix those modules is a dubious > strategy, I think. > > /me shrug. If their modules fail with a new versio

Re: Subtest fail with singletons

2009-06-29 Thread David E. Wheeler
On Jun 29, 2009, at 9:50 AM, Ovid wrote: And Test::Exception and many, many other Test:: modules. It's a very common pattern and getting all authors to agree to fix those modules is a dubious strategy, I think. /me shrug. If their modules fail with a new version of T::B, they have to fix

Re: Subtest fail with singletons

2009-06-29 Thread Ovid
- Original Message > From: David E. Wheeler > To: Ovid > Cc: perl-qa@perl.org > Sent: Monday, 29 June, 2009 17:38:15 > Subject: Re: Subtest fail with singletons > > On Jun 29, 2009, at 2:19 AM, Ovid wrote: > > >my $Test = Test::Builder->new

Re: Subtest fail with singletons

2009-06-29 Thread David E. Wheeler
On Jun 29, 2009, at 2:19 AM, Ovid wrote: my $Test = Test::Builder->new; If every test function simply had that line in the function, rather than trying to share this across all test functions, the code would work fine. Not sure of the best way of handling this, but it's annoying as h

Re: Subtest fail with singletons

2009-06-29 Thread Ovid
erlfoundation.org/perl6 - Original Message > From: Ovid > To: perl-qa@perl.org > Sent: Monday, 29 June, 2009 10:19:19 > Subject: Subtest fail with singletons > > > The following subtest code fails badly: > > use Test::More tests => 2; > use Test::XML; >

Subtest fail with singletons

2009-06-29 Thread Ovid
The following subtest code fails badly: use Test::More tests => 2; use Test::XML; ok 1; subtest 'FAIL!' => sub { plan tests => 1; is_xml '', '', 'Singleton fail'; }; __END__ xml.t .. 1..2 ok 1 1..1 Cannot run test (Singleton fail)