Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

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

by adrianh (Chancellor)
on Oct 12, 2007 at 12:56 UTC ( [id://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

Replies are listed 'Best First'.
Re^3: Any way to access the contents of a block eval?
by ikegami (Patriarch) 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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://644467]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-04-19 14:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found