summaryrefslogtreecommitdiff
path: root/gnu/usr.bin/perl/ext/Errno/t/Errno.t
blob: a6b08e03f9955ea7d4e8821de74425fd152f404d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!./perl

BEGIN {
    unless(grep /blib/, @INC) {
	chdir 't' if -d 't';
	if ($^O eq 'MacOS') { 
	    @INC = qw(: ::lib ::macos:lib); 
	} else { 
	    @INC = '../lib'; 
	}
    }
}

use Errno;

print "1..6\n";

print "not " unless @Errno::EXPORT_OK;
print "ok 1\n";
die unless @Errno::EXPORT_OK;

$err = $Errno::EXPORT_OK[0];
$num = &{"Errno::$err"};

print "not " unless &{"Errno::$err"} == $num;
print "ok 2\n";

$! = $num;
# Some systems have ESUCCESS 0, that's why exists instead of boolean.
print "not " unless exists $!{$err};
print "ok 3\n";

$! = 0;
print "not " if $!{$err};
print "ok 4\n";

$s1 = join(",",sort keys(%!));
$s2 = join(",",sort @Errno::EXPORT_OK);

if($s1 ne $s2) {
    my @s1 = keys(%!);
    my @s2 = @Errno::EXPORT_OK;
    my(%s1,%s2);
    @s1{@s1} = ();
    @s2{@s2} = ();
    delete @s2{@s1};
    delete @s1{@s2};
    print "# These are only in \%!\n";
    print "# ",join(" ",map { "'$_'" } keys %s1),"\n";
    print "# These are only in \@EXPORT_OK\n";
    print "# ",join(" ",map { "'$_'" } keys %s2),"\n";
    print "not ";
}

print "ok 5\n";

eval { exists $!{[]} };
print $@ ? "not ok 6\n" : "ok 6\n";