xref: /openbsd/gnu/usr.bin/perl/ext/Errno/t/Errno.t (revision 7b36286a)
1#!./perl
2
3BEGIN {
4    unless(grep /blib/, @INC) {
5	chdir 't' if -d 't';
6	if ($^O eq 'MacOS') {
7	    @INC = qw(: ::lib ::macos:lib);
8	} else {
9	    @INC = '../lib';
10	}
11    }
12}
13
14use Errno;
15
16print "1..6\n";
17
18print "not " unless @Errno::EXPORT_OK;
19print "ok 1\n";
20die unless @Errno::EXPORT_OK;
21
22$err = $Errno::EXPORT_OK[0];
23$num = &{"Errno::$err"};
24
25print "not " unless &{"Errno::$err"} == $num;
26print "ok 2\n";
27
28$! = $num;
29# Some systems have ESUCCESS 0, that's why exists instead of boolean.
30print "not " unless exists $!{$err};
31print "ok 3\n";
32
33$! = 0;
34print "not " if $!{$err};
35print "ok 4\n";
36
37$s1 = join(",",sort keys(%!));
38$s2 = join(",",sort @Errno::EXPORT_OK);
39
40if($s1 ne $s2) {
41    my @s1 = keys(%!);
42    my @s2 = @Errno::EXPORT_OK;
43    my(%s1,%s2);
44    @s1{@s1} = ();
45    @s2{@s2} = ();
46    delete @s2{@s1};
47    delete @s1{@s2};
48    print "# These are only in \%!\n";
49    print "# ",join(" ",map { "'$_'" } keys %s1),"\n";
50    print "# These are only in \@EXPORT_OK\n";
51    print "# ",join(" ",map { "'$_'" } keys %s2),"\n";
52    print "not ";
53}
54
55print "ok 5\n";
56
57eval { exists $!{[]} };
58print $@ ? "not ok 6\n" : "ok 6\n";
59