Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

40 lines (29 sloc) 0.815 kB
use v6;
use Test;
plan 2;
sub nonce () { return ".{$*PID}." ~ (1..1000).pick() }
my $filename = 'tempfile_rebindstdhandles' ~ nonce();
# Test for re-binding $*OUT.
#?rakudo skip 'contextual rebinding regression'
{
my $old_out := $*OUT;
$*OUT := open($filename, :w);
print "OH ";
say "HAI!";
$*OUT.close();
$*OUT := $old_out;
is(slurp($filename), "OH HAI!\n", 'rebound $*OUT to file handle OK');
unlink($filename);
}
# Test for re-binding $*ERR.
#?rakudo skip 'warn does not yet use $*ERR'
{
my $old_err := $*ERR;
$*ERR := open($filename, :w);
warn("OH NOES OUT OF CHEEZBURGER\n");
$*ERR.close();
$*ERR := $old_err;
is(slurp($filename), "OH NOES OUT OF CHEEZBURGER\n", 'rebound $*ERR to file handle OK');
unlink($filename);
}
# vim: ft=perl6
Jump to Line
Something went wrong with that request. Please try again.