develooper Front page | perl.perl6.users | Postings from October 2018

Re: Appropriate last words

Thread Previous | Thread Next
From:
Brian Duggan
Date:
October 25, 2018 02:47
Subject:
Re: Appropriate last words
Message ID:
20181025024707.GA1096@localhost
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 );

&exit.wrap: -> $status { $exit-args = $status; fail }
&note.wrap: -> |c { $note-args = c; callsame; }

$*ERR.^find_method('print').wrap: -> |c { True; }

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;

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About