### ----------------------------------------------------
### -- Trap
### -- Licenses: Artistic-2.0
### -- Authors: Elizabeth Mattijsen
### -- File: t/01-basic.rakutest
### ----------------------------------------------------
use Test;
use Trap;

plan 4;

my $out;
my $err;
{   # separate capturing
    $out = Trap(my $*OUT);
    $err = Trap(my $*ERR);
    say "Hello world!";
    note "Goodbye!"
}
is $out.text, "Hello world!\n", 'is out text ok';
is $err.text, "Goodbye!\n",     'is err text ok';

my $merged;
{   # merged capturing
    $merged = Trap(my $*OUT, my $*ERR);
    put "Hello world!";
    note "Goodbye!"
}
is $merged.text, "Hello world!\nGoodbye!\n", 'is merged text ok';

my $new;
{   # creating the object manually
    $new = my $*OUT = Trap.new;
    print "Hello world!";
}
is $new.text, 'Hello world!', 'is new text ok';

# vim: expandtab shiftwidth=4


