On Sat, Jun 19, 2004 at 09:11:43PM -0200, Gabor Szabo wrote:
> 
> I would like to test a module for unsuccessful "require" while the
> required module is installed. That is I'd like ot test how my code would
> work if Foo.pm was not present.
> 
> In the middle of a module I have code such as
> 
> eval {
>    require Foo;
> };
> if ($@) {
>    foo();
> } else {
>    my_own_foo();
> }
> 
> I already installed Foo so I can test the behaviour of the code
> with Foo. How can I test now the behaviour without Foo ?
> Removing Foo.pm is not an option.
> 
> I have some ideas outlined below, but I'd like to get your recommendation.

[snip]

> In general I'd like to get your opinion on how to mock unsuccessful
> require.

local *CORE::GLOBAL::require = sub { die "require $_[0] failed" };

Goes back to before 5.6.  I think it came in in 5.004.

-- 
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net

Reply via email to