App-MtAws
view release on metacpan or search on metacpan
t/unit/test_test.t view on Meta::CPAN
}
{
my $out = '';
my $res = capture_stdout $out => sub {
print "Test123\nTest456";
42;
};
is $res, 42;
is $out, "Test123\nTest456", "should work with stdout when out defined";
}
{
my $res = capture_stderr my $out, sub {
print STDERR "Test123\nTest456";
42;
};
is $res, 42;
is $out, "Test123\nTest456", "should work with stderr when out is undefined";
}
{
my $out = '';
my $res = capture_stderr $out => sub {
print STDERR "Test123\nTest456";
42;
};
is $res, 42;
is $out, "Test123\nTest456", , "should work with stdout when out is defined";
}
{ # test is_iv_without_pv
ok is_iv_without_pv(1);
ok !is_iv_without_pv("1");
my $x = 1;
ok is_iv_without_pv($x);
my $z = "$x";
ok !is_iv_without_pv($x);
my $y = "2";
$y = $y + 0;
ok !is_iv_without_pv($y);
}
# is_posix_root
{
if ($^O eq 'cygwin') {
require Win32;
ok ( (!! is_posix_root()) == (!!Win32::IsAdminUser()) );
ok ( (!! is_posix_root()) == (!!Win32::IsAdminUser()) ); # double check, as it's cached
} else {
ok ( (!! is_posix_root()) == (!! ($>==0)) );
ok ( (!! is_posix_root()) == (!! ($>==0)) ); # double check, as it's cached
}
}
{
use JSON::XS 1;
my $json = JSON::XS->new->utf8->allow_nonref;
my $s = $json->encode({myfield => JSON_XS_TRUE});
like $s, qr/\:\s*true\s*\}/;
ok $json->decode($s)->{myfield};
$s = $json->encode({myfield => JSON_XS_FALSE});
like $s, qr/\:\s*false\s*\}/;
ok !$json->decode($s)->{myfield};
}
1;
( run in 0.504 second using v1.01-cache-2.11-cpan-39bf76dae61 )