in reply to Re: Test::More usage to test functions that die
in thread Test::More usage to test functions that die
This wont work unless all your code is in main:: (and even then its a delicate situation at best)
However, what you are talking about is not unlike the ideas behind MockObjects, see Test::MockObject and Test::MockModule for more info.#!/usr/bin/perl sub main::croak { print "I croaked"; } { package Test; use Carp; sub myfunc { croak("I am dying"); } } eval { Test::myfunc(); }; print $@ if $@; *myfunc = \&Test::myfunc; eval { myfunc(); }; print $@ if $@; __OUTPUT__ I am dying at test.pl line 18 I am dying at test.pl line 26
-stvn
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Test::More usage to test functions that die
by trammell (Priest) on Dec 08, 2004 at 16:22 UTC |
In Section
Seekers of Perl Wisdom