use
5.014;
use
if
CAPTURE_TINY,
'Capture::Tiny'
,
qw( capture_stdout )
;
BEGIN {
use_ok
'Win32::Console::DotNet'
;
use_ok
'System'
;
use_ok
'ConsoleColor'
;
}
SKIP: { skip
'Not supported iOS, MacCatalyst, or tvOS.'
, 1
if
os_type eq
'iphoneos'
;
subtest
'InvalidColors'
=>
sub
{
plan
tests
=> 2;
throws_ok { Console->BackgroundColor(42) }
qr/ArgumentException/
;
throws_ok { Console->BackgroundColor(42) }
qr/ArgumentException/
;
}}
SKIP: { skip
'Not supported iOS, MacCatalyst, or tvOS.'
, 1
if
os_type eq
'iphoneos'
;
subtest
'RoundtrippingColor'
=>
sub
{
plan
tests
=> 2;
lives_ok { Console->BackgroundColor( Console->BackgroundColor ) };
lives_ok { Console->ForegroundColor( Console->ForegroundColor ) };
}}
subtest
'ForegroundColor'
=>
sub
{
plan
tests
=> 2;
lives_ok { Console->ForegroundColor };
lives_ok { Console->ForegroundColor( ConsoleColor->Red ) };
};
subtest
'BackgroundColor'
=>
sub
{
plan
tests
=> 2;
lives_ok { Console->BackgroundColor };
lives_ok { Console->BackgroundColor( ConsoleColor->Red ) };
};
SKIP: { skip
'Not supported iOS, MacCatalyst, or tvOS.'
, 1
if
os_type eq
'iphoneos'
;
skip
'Capture::Tiny not installed'
, 1
unless
CAPTURE_TINY;
subtest
'RedirectedOutputDoesNotUseAnsiSequences'
=>
sub
{
plan
tests
=> 3;
my
$data
= capture_stdout(
sub
{
lives_ok {
Console->Write(
'1'
);
Console->ForegroundColor( ConsoleColor->Blue );
Console->Write(
'2'
);
Console->BackgroundColor( ConsoleColor->Red );
Console->Write(
'3'
);
Console->ResetColor();
Console->Write(
'4'
);
}
});
is
index
(
$data
, Esc), -1;
is
$data
,
"1234"
;
}}
use
constant
TermIsSetAndRemoteExecutorIsSupported
=> !!
$ENV
{
"TERM"
};
SKIP: { skip
'Platform specific'
, 1
unless
is_os_type(
'Unix'
);
skip
'Not supported iOS, MacCatalyst, or tvOS.'
, 1
if
os_type eq
'iphoneos'
;
skip
'TERM is not set'
, 1
unless
TermIsSetAndRemoteExecutorIsSupported;
subtest
'RedirectedOutput_EnvVarSet_EmitsAnsiCodes'
=>
sub
{
plan
tests
=> 6;
for
my
$envVar
(
undef
,
'1'
,
'true'
,
'tRuE'
,
'0'
,
'false'
) {
TODO: {
local
$TODO
=
'Action not implemented'
;
fail;
}
}
}}
done_testing;