Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^2: Any way to access the contents of a block eval?

by adrianh (Chancellor)
on Oct 12, 2007 at 12:56 UTC ( #644467=note: print w/ replies, xml ) Need Help??


in reply to Re: Any way to access the contents of a block eval?
in thread Any way to access the contents of a block eval?

However, I don't see the use of this. The contents of an eval BLOCK doesn't change. What's the point of printing out something you already know?

I was thinking of nicer default diagnostic messages for Test::Exception - so instead of writing:

lives_ok { $o->something } 'something worked';

you could just write

lives_ok { $o->something };

And still get a vaguely nice diagnostic

ok - $o->something lived


Comment on Re^2: Any way to access the contents of a block eval?
Select or Download Code
Replies are listed 'Best First'.
Re^3: Any way to access the contents of a block eval?
by ikegami (Pope) on Oct 12, 2007 at 17:00 UTC

    In that case, chromatic's code simplifies to

    use B::Deparse qw( ); my $deparse = B::Deparse->new(); sub lives_ok(&;$) { my ($code, $desc) = @_; $desc = $deparse->coderef2text($code) if !defined($desc); return Text::Exception::lives_ok($code, $desc); }

    Be careful to avoid accidently overriding your own functions with those from the module you are extending.

      D'oh! I knew about that.
Re^3: Any way to access the contents of a block eval?
by chromatic (Archbishop) on Oct 12, 2007 at 16:29 UTC

    Ah, so you already have the sub reference. Even easier.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://644467]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (12)
As of 2015-07-08 06:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (94 votes), past polls