On Monday, July 1, 2002, at 03:21  pm, Janek Schleicher wrote:

> Hello!
>
> On Sun, 30 Jun 2002, Adrian Howard wrote:
>
>> Nothing like it AFAIK - sounds useful. I've got places where I'm doing
>> this sort of thing, but I slurp up STDERR rather than wrapping
>> SIG{__WARN__} (which I assume is what you're planning?)
>
> I wanted to use SIG{__WARN__},
> but if I know some code where it makes problem,
> perhaps I'll use another implementation.
>
> Both ways can be problematic,
> as SIG{__WARN__} can be overwritten and
> STDERR could be changed internally.

Personally, I think it should be wrapping SIG{__WARN__}, or the name
should be changed to something like Test::STDERR with stderr_like,
etc.

If you want to go the latter route I did a quick 'n' dirty
Test::Output module for capturing stuff sent to filehandles, allowing
you to do:

   output_is     { hello() } "hello world\n", STDOUT, "hello world";
   output_isnt   { hello() } "goodbye",       STDOUT, "not goodbye";
   output_unlike { hello() } qr/bye/,         STDOUT, "didn't print bye";
   output_like   { hello() } qr/hello/,       STDOUT, "printed hello";
   like(Test::Output->last, qr/world/, "... and world");

I'm not entirely happy with implementation or API, but I've not had
the spare time to give it any thought. The code's at
<http://www.quietstars.com/perl/> if you're interested ;-)

There is a useful difference between the production of a warning, and
the way the app chooses to handle the warning. If I choose to send my
warnings off to syslog by changing SIG{__WARN__} I should still be
able to test for the warnings with warn_like, etc.

[snip]
>> Maybe warn_like or warning_like instead of warns_ok (so it's like
>> Test::More's "like")?
>
> Great idea.
> (In fact I took your Test::Exception module as pattern,
>  so I only translated dies_ok to warns_ok :-) )

My fault :-) In hindsight I should have done a separate throws_like and 
throws_isa.

Adrian
--
Adrian Howard  <[EMAIL PROTECTED]>
phone: 01929 550720  fax: 0870 131 3033  www.quietstars.com

Reply via email to