Revision history for Sys-Syslog
+0.12 2006.01.07
+ [CODE] Merged some modifications from bleadperl.
+ [DOC] Added a link to an article about Sys::Syslog.
+ [TESTS] Removed optional dependency on Test::Exception.
+ [TESTS] Improved t/constant.t
+ [TESTS] Rewrote t/constants.t because future versions of
+ ExtUtils::Constant will prevent the constant() function from
+ being directly called.
+
0.11 2005.12.28
- [BUGFIX] setlogmask() now behaves liek its C counterpart.
+ [BUGFIX] setlogmask() now behaves like its C counterpart.
[CODE] Can now export and use the macros.
[CODE] Support for three Exporter tags.
[CODE] XSLoader is now optional.
- Linux 2.6, gcc 3.4.1
- FreeBSD 4.7, gcc 2.95.4
- - Mac OS X 10.2.6, gcc 3.1
+ - Mac OS X 10.4, gcc 4.0.1
Sys::Syslog should on any Perl since 5.6.0. This module has been
tested by the author to check that it works with the following
- Perl 5.8.5 i386-linux-thread-multi (vendor build)
- Perl 5.6.1 i386-freebsd (custom build)
- Perl 5.8.7 i386-freebsd (custom build)
- - Perl 5.6.0 darwin (vendor build)
- - Perl 5.8.7 cygwin-thread-multi-64int (vendor build)
+ - Perl 5.8.6 darwin-thread-multi-2level (vendor build)
See also the corresponding CPAN Testers page:
- http://testers.cpan.org/show/Net-Pcap.html
+ http://testers.cpan.org/show/Sys-Syslog.html
SUPPORT AND DOCUMENTATION
#!/usr/bin/perl -T
use strict;
+use File::Spec;
use Test::More;
-my @names;
-BEGIN {
- if(open(MACROS, 'macros.all')) {
- @names = map {chomp;$_} <MACROS>;
- close(MACROS);
- plan tests => @names + 3;
- } else {
- plan skip_all => "can't read 'macros.all': $!"
- }
-}
-use Sys::Syslog;
-eval "use Test::Exception"; my $has_test_exception = !$@;
+my $macrosall = $ENV{PERL_CORE} ? File::Spec->catfile(qw(.. ext Sys Syslog macros.all))
+ : 'macros.all';
+open(MACROS, $macrosall) or plan skip_all => "can't read '$macrosall': $!";
+my @names = map {chomp;$_} <MACROS>;
+close(MACROS);
+plan tests => @names * 2 + 2;
-# Testing error messages
-SKIP: {
- skip "Test::Exception not available", 1 unless $has_test_exception;
-
- # constant() errors
- throws_ok(sub {
- Sys::Syslog::constant()
- }, '/^Usage: Sys::Syslog::constant\(sv\)/',
- "calling constant() with no argument");
-}
+my $callpack = my $testpack = 'Sys::Syslog';
+eval "use $callpack";
-# Testing constant()
-like( Sys::Syslog::constant('This'),
- '/^This is not a valid Sys::Syslog macro/',
- "calling constant() with a non existing name" );
+eval "${callpack}::This()";
+like( $@, "/^This is not a valid $testpack macro/", "trying a non-existing macro");
-like( Sys::Syslog::constant('NOSUCHNAME'),
- '/^NOSUCHNAME is not a valid Sys::Syslog macro/',
- "calling constant() with a non existing name" );
+eval "${callpack}::NOSUCHNAME()";
+like( $@, "/^NOSUCHNAME is not a valid $testpack macro/", "trying a non-existing macro");
# Testing all macros
if(@names) {
for my $name (@names) {
- like( Sys::Syslog::constant($name),
- '/^(?:\d+|Your vendor has not defined Sys::Syslog macro '.$name.', used)$/',
- "checking that $name is a number (".Sys::Syslog::constant($name).")" );
+ SKIP: {
+ $name =~ /^(\w+)$/ or skip "invalid name '$name'", 2;
+ $name = $1;
+ my $v = eval "${callpack}::$name()";
+
+ if($v =~ /^\d+$/) {
+ is( $@, '', "calling the constant $name as a function" );
+ like( $v, '/^\d+$/', "checking that $name is a number ($v)" );
+
+ } else {
+ like( $@, "/^Your vendor has not defined $testpack macro $name/",
+ "calling the constant via its name" );
+ skip "irrelevant test in this case", 1
+ }
+ }
}
}
-