I'm trying to understand this. Would someone provide a bit more explanation?

On 25/10/2018 10:47, Brian Duggan wrote:
On Sunday, October 21, Richard Hainsworth wrote:
so .. either I use your suggestion of 'exit note $message' which I find
elegant, but so far difficult to test.
You could always wrap things, e.g. something like --

my ( $exit-args, $note-args );

The wrap documentation states:

Wraps (i.e. in-place modifies) the routine. That means a call to this routine first calls |&wrapper|, which then can (but doesn't have to) call the original routine with the |callsame|, |callwith|, |nextsame| and |nextwith| dispatchers. The return value from the routine is also the return value from the wrapper.


&exit.wrap: -> $status { $exit-args = $status; fail }
Is the call to 'fail' replicating the original action of &exit?
&note.wrap: -> |c { $note-args = c; callsame; }
Does this mean that the next routine in a chain (in this case `exit note ... `), so in fact `exit`, is called?

$*ERR.^find_method('print').wrap: -> |c { True; }
This wrap I am not so clear about. Why is `^find_method('print') needed?

sub run {
   exit note 'bye';
}

use Test;
try run;
is $note-args, 'bye', 'output correct';
is $exit-args.Int, 1, 'exit status is 1';
done-testing;

Reply via email to