Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 12d03bf7cd
Fetching contributors…

Cannot retrieve contributors at this time

file 39 lines (29 sloc) 0.815 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
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
Something went wrong with that request. Please try again.