Change 13739 by jhi@alpha on 2001/12/17 18:47:41
Subject: [PATCH] more POSIX tests, and more autoloading
From: Nicholas Clark <[EMAIL PROTECTED]>
Date: Mon, 17 Dec 2001 18:27:47 +0000
Message-ID: <[EMAIL PROTECTED]>
Affected files ...
.... //depot/perl/ext/POSIX/POSIX.pm#25 edit
.... //depot/perl/ext/POSIX/t/posix.t#4 edit
Differences ...
==== //depot/perl/ext/POSIX/POSIX.pm#25 (text) ====
Index: perl/ext/POSIX/POSIX.pm
--- perl/ext/POSIX/POSIX.pm.~1~ Mon Dec 17 12:00:05 2001
+++ perl/ext/POSIX/POSIX.pm Mon Dec 17 12:00:05 2001
@@ -6,7 +6,7 @@
use XSLoader ();
-our $VERSION = "1.04" ;
+our $VERSION = "1.05" ;
# Grandfather old foo_h form to new :foo_h form
my $loaded;
@@ -49,6 +49,13 @@
goto &$AUTOLOAD;
}
+sub POSIX::SigAction::new {
+ bless {HANDLER => $_[1], MASK => $_[2], FLAGS => $_[3] || 0}, $_[0];
+}
+
+1;
+__END__
+
sub usage {
my ($mess) = @_;
croak "Usage: POSIX::$mess";
@@ -65,18 +72,6 @@
croak "Unimplemented: POSIX::$mess";
}
-############################
-package POSIX::SigAction;
-
-sub new {
- bless {HANDLER => $_[1], MASK => $_[2], FLAGS => $_[3] || 0}, $_[0];
-}
-
-############################
-package POSIX; # return to package POSIX so AutoSplit is happy
-1;
-__END__
-
sub assert {
usage "assert(expr)" if @_ != 1;
if (!$_[0]) {
@@ -744,7 +739,7 @@
ctype_h => [qw(isalnum isalpha iscntrl isdigit isgraph islower
isprint ispunct isspace isupper isxdigit tolower toupper)],
- dirent_h => [qw()],
+ dirent_h => [],
errno_h => [qw(E2BIG EACCES EADDRINUSE EADDRNOTAVAIL EAFNOSUPPORT
EAGAIN EALREADY EBADF EBUSY ECHILD ECONNABORTED
@@ -781,7 +776,7 @@
LDBL_MAX LDBL_MAX_10_EXP LDBL_MAX_EXP
LDBL_MIN LDBL_MIN_10_EXP LDBL_MIN_EXP)],
- grp_h => [qw()],
+ grp_h => [],
limits_h => [qw( ARG_MAX CHAR_BIT CHAR_MAX CHAR_MIN CHILD_MAX
INT_MAX INT_MIN LINK_MAX LONG_MAX LONG_MIN MAX_CANON
@@ -801,7 +796,7 @@
math_h => [qw(HUGE_VAL acos asin atan ceil cosh fabs floor fmod
frexp ldexp log10 modf pow sinh tan tanh)],
- pwd_h => [qw()],
+ pwd_h => [],
setjmp_h => [qw(longjmp setjmp siglongjmp sigsetjmp)],
@@ -813,7 +808,7 @@
SIG_IGN SIG_SETMASK SIG_UNBLOCK raise sigaction signal
sigpending sigprocmask sigsuspend)],
- stdarg_h => [qw()],
+ stdarg_h => [],
stddef_h => [qw(NULL offsetof)],
@@ -842,9 +837,9 @@
S_ISUID S_IWGRP S_IWOTH S_IWUSR S_IXGRP S_IXOTH S_IXUSR
fstat mkfifo)],
- sys_times_h => [qw()],
+ sys_times_h => [],
- sys_types_h => [qw()],
+ sys_types_h => [],
sys_utsname_h => [qw(uname)],
@@ -882,7 +877,7 @@
getpid getuid isatty lseek pathconf pause setgid setpgid
setsid setuid sysconf tcgetpgrp tcsetpgrp ttyname)],
- utime_h => [qw()],
+ utime_h => [],
);
==== //depot/perl/ext/POSIX/t/posix.t#4 (text) ====
Index: perl/ext/POSIX/t/posix.t
--- perl/ext/POSIX/t/posix.t.~1~ Mon Dec 17 12:00:05 2001
+++ perl/ext/POSIX/t/posix.t Mon Dec 17 12:00:05 2001
@@ -11,7 +11,7 @@
}
require "./test.pl";
-plan(tests => 31);
+plan(tests => 38);
use POSIX qw(fcntl_h signal_h limits_h _exit getcwd open read strftime write
@@ -185,6 +185,31 @@
}
}
+SKIP: {
+ skip("no kill() support on Mac OS", 1) if $Is_MacOS;
+ is (eval "kill 0", 0, "check we have CORE::kill")
+ or print "\$\@ is " . _qq($@) . "\n";
+}
+
+# Check that we can import the POSIX kill routine
+POSIX->import ('kill');
+my $result = eval "kill 0";
+is ($result, undef, "we should now have POSIX::kill");
+# Check usage.
+like ($@, qr/^Usage: POSIX::kill\(pid, sig\)/, "check its usage message");
+
+# Check unimplemented.
+$result = eval {POSIX::offsetof};
+is ($result, undef, "offsetof should fail");
+like ($@, qr/^Unimplemented: POSIX::offsetof\(\) is C-specific/,
+ "check its unimplemented message");
+
+# Check reimplemented.
+$result = eval {POSIX::fgets};
+is ($result, undef, "fgets should fail");
+like ($@, qr/^Use method IO::Handle::gets\(\) instead/,
+ "check its redef message");
+
$| = 0;
# The following line assumes buffered output, which may be not true:
print '@#!*$@(!@#$' unless ($Is_MacOS || $Is_OS2 || $Is_UWin || $Is_OS390 ||
End of Patch.