develooper Front page | perl.qa | Postings from August 2005

Re: Test::Exception and XS code

Thread Previous | Thread Next
From:
Sébastien Aperghis-Tramoni
Date:
August 15, 2005 09:26
Subject:
Re: Test::Exception and XS code
Message ID:
40ECEEAA-0DA9-11DA-ACBC-000502F3279F@free.fr
Yitzchak Scott-Thoennes wrote:

> The throw_ok { ... } syntax only works because the throw_ok sub exists
> and has a prototype that specifies a subref is expected; if you don't
> load Test::Exception by the time the throw_ok call is compiled, it
> is parsed as an indirect object call of the "throw_ok" method on the
> object or class returned by the {} block:
>
> $ perl -MO=Deparse,-p -we'throws_ok {  Net::Pcap::lookupdev() } 
> "/^Usage: Net::Pcap::lookupdev\(err\)/", "calling lookupdev() with no 
> argument"'
> BEGIN { $^W = 1; }
> do {
>     Net::Pcap::lookupdev()
> }->throws_ok('/^Usage: Net::Pcap::lookupdev(err)/', 'calling 
> lookupdev() with no
>  argument');
> -e syntax OK
>
> which is perfectly valid perl, but unlikely to do what you want.

Understood. Thanks for the explanation.


Sébastien Aperghis-Tramoni
  -- - --- -- - -- - --- -- - --- -- - --[ http://maddingue.org ]
Close the world, txEn eht nepO


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About