From: Nicholas Clark Date: Mon, 17 Dec 2001 18:27:47 +0000 (+0000) Subject: more POSIX tests, and more autoloading X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d4742b2c4fb9d3d58f0b4211ec254bb804bb6fd5;p=p5sagit%2Fp5-mst-13.2.git more POSIX tests, and more autoloading Message-ID: <20011217182747.D21702@plum.flirble.org> p4raw-id: //depot/perl@13739 --- diff --git a/ext/POSIX/POSIX.pm b/ext/POSIX/POSIX.pm index 9336670..92a3182 100644 --- a/ext/POSIX/POSIX.pm +++ b/ext/POSIX/POSIX.pm @@ -6,7 +6,7 @@ use AutoLoader; 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 @@ sub AUTOLOAD { 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 @@ sub unimpl { 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 @@ sub load_imports { 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 @@ sub load_imports { 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 @@ sub load_imports { 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 @@ sub load_imports { 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 @@ sub load_imports { 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 @@ sub load_imports { getpid getuid isatty lseek pathconf pause setgid setpgid setsid setuid sysconf tcgetpgrp tcsetpgrp ttyname)], - utime_h => [qw()], + utime_h => [], ); diff --git a/ext/POSIX/t/posix.t b/ext/POSIX/t/posix.t index 81c97e5..49357a6 100644 --- a/ext/POSIX/t/posix.t +++ b/ext/POSIX/t/posix.t @@ -11,7 +11,7 @@ BEGIN { } 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 @@ try_strftime("Fri Mar 31 00:00:00 2000 091", 0,0,0, 31,2,100); } } +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 ||