6 use constant NON_EXISTENT_OS => 'titanix'; #the system they said could not go down...
8 #--------------------------------------------------------------------------#
10 #--------------------------------------------------------------------------#
12 require_ok( 'Perl::OSType' );
14 can_ok( 'Perl::OSType', 'os_type' );
16 my @functions = qw/os_type is_os_type/ ;
17 for my $sub ( @functions ) {
18 ok( eval { Perl::OSType->import($sub); 1 }, "importing $sub()" );
19 can_ok( 'main', $sub );
22 my $test_pkg = "testpackage$$";
24 ok( eval "package $test_pkg; use Perl::OSType ':all'; 1",
25 "Testing 'use Perl::OSType qw/:all/'"
28 can_ok( $test_pkg, @functions );
31 #--------------------------------------------------------------------------#
33 #--------------------------------------------------------------------------#
36 my $fcn = 'os_type()';
38 ok( my $current_type = os_type(), "$fcn: without arguments" );
40 is( $current_type, os_type( $^O ), "... matches os_type($^O)" );
42 is(os_type( NON_EXISTENT_OS ), '', "$fcn: unknown OS returns empty string");
44 is(os_type( '' ), '', "$fcn: empty string returns empty string");
48 is(os_type( undef ), 'Unix', "$fcn: explicit undef uses $^O");
51 #--------------------------------------------------------------------------#
53 #--------------------------------------------------------------------------#
56 my $fcn = 'is_os_type()';
58 is(is_os_type(NON_EXISTENT_OS), '', "$fcn: non-existent type is false");
60 is(is_os_type(''), undef, "$fcn: empty string type is false");
62 is(is_os_type('Unix', NON_EXISTENT_OS), '', "$fcn: non-existent OS is false");
65 ok( ! is_os_type( 'Unix' ), "$fcn: false" );
66 ok( is_os_type( 'VOS' ), "$fcn: true" );
67 ok( ! is_os_type(), "$fcn: false if no type provided" );