Blame t/OSType.t

Packit 65f819
use strict;
Packit 65f819
use warnings;
Packit 65f819
Packit 65f819
use Test::More 0.88;
Packit 65f819
Packit 65f819
use constant NON_EXISTENT_OS => 'titanix'; #the system they said could not go down...
Packit 65f819
Packit 65f819
#--------------------------------------------------------------------------#
Packit 65f819
# API tests
Packit 65f819
#--------------------------------------------------------------------------#
Packit 65f819
Packit 65f819
require_ok('Perl::OSType');
Packit 65f819
Packit 65f819
can_ok( 'Perl::OSType', 'os_type' );
Packit 65f819
Packit 65f819
my @functions = qw/os_type is_os_type/;
Packit 65f819
for my $sub (@functions) {
Packit 65f819
    ok( eval { Perl::OSType->import($sub); 1 }, "importing $sub()" );
Packit 65f819
    can_ok( 'main', $sub );
Packit 65f819
}
Packit 65f819
Packit 65f819
my $test_pkg = "testpackage$$";
Packit 65f819
Packit 65f819
ok( eval "package $test_pkg; use Perl::OSType ':all'; 1",
Packit 65f819
    "Testing 'use Perl::OSType qw/:all/'" );
Packit 65f819
Packit 65f819
can_ok( $test_pkg, @functions );
Packit 65f819
Packit 65f819
#--------------------------------------------------------------------------#
Packit 65f819
# os_type
Packit 65f819
#--------------------------------------------------------------------------#
Packit 65f819
Packit 65f819
{
Packit 65f819
    my $fcn = 'os_type()';
Packit 65f819
Packit 65f819
    ok( my $current_type = os_type(), "$fcn: without arguments" );
Packit 65f819
Packit 65f819
    is( $current_type, os_type($^O), "... matches os_type($^O)" );
Packit 65f819
Packit 65f819
    is( os_type(NON_EXISTENT_OS), '', "$fcn: unknown OS returns empty string" );
Packit 65f819
Packit 65f819
    is( os_type(''), '', "$fcn: empty string returns empty string" );
Packit 65f819
Packit 65f819
    local $^O = 'linux';
Packit 65f819
Packit 65f819
    is( os_type(undef), 'Unix', "$fcn: explicit undef uses $^O" );
Packit 65f819
}
Packit 65f819
Packit 65f819
#--------------------------------------------------------------------------#
Packit 65f819
# is_os_type
Packit 65f819
#--------------------------------------------------------------------------#
Packit 65f819
Packit 65f819
{
Packit 65f819
    my $fcn = 'is_os_type()';
Packit 65f819
Packit 65f819
    is( is_os_type(NON_EXISTENT_OS), '', "$fcn: non-existent type is false" );
Packit 65f819
Packit 65f819
    is( is_os_type(''), undef, "$fcn: empty string type is false" );
Packit 65f819
Packit 65f819
    is( is_os_type( 'Unix', NON_EXISTENT_OS ), '', "$fcn: non-existent OS is false" );
Packit 65f819
Packit 65f819
    local $^O = 'vos';
Packit 65f819
    ok( !is_os_type('Unix'), "$fcn: false" );
Packit 65f819
    ok( is_os_type('VOS'),   "$fcn: true" );
Packit 65f819
    ok( !is_os_type(),       "$fcn: false if no type provided" );
Packit 65f819
}
Packit 65f819
Packit 65f819
done_testing;
Packit 65f819