### ----------------------------------------------------
### -- Shell::Capture
### -- Licenses: Artistic-2.0
### -- Authors: Peter Pentchev
### -- File: t/02-nl-enc.rakutest
### ----------------------------------------------------
#!/usr/bin/env raku

use v6.c;

use Test;

plan 6;

use lib 'lib';

use Shell::Capture;

my Shell::Capture $c .= capture($*EXECUTABLE, '-v');
is $c.exitcode, 0, 'raku -v succeeded';
isnt $c.lines.elems, 0, 'raku -v output something';

$c .= capture($*EXECUTABLE, '-e', 'print "one#two#three#four#"', :nl('#'));
is $c.exitcode, 0, 'raku -e "print" succeeded';
is-deeply $c.lines, Array[Str].new(<one two three four>),
    'raku -e "print" said the right thing';

$c .= capture-check($*EXECUTABLE, '-e', 'print "one\0two\0thrée"', :nl("\0"), :enc('UTF-8'));
is-deeply $c.lines, Array[Str].new(<one two thrée>),
    'raku -e "print no nl at eol" said the right thing';

$c .= capture-check($*EXECUTABLE, '-e', 'print "\x00e1" ~ "ab\x0430"', :nl('ab'), :enc('ISO-8859-1'));
is-deeply $c.lines, Array[Str].new(<Ã¡ Ð°>),
    'decoded from ISO-8859-1';


