summaryrefslogtreecommitdiff
path: root/gnu/usr.bin/perl/ext/Sys/Syslog/t/constants.t
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2006-03-28 18:50:00 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2006-03-28 18:50:00 +0000
commit21632774c37bb8874de17fa6ad931c73d19518cd (patch)
treecd08ee24e9b82c03c8e191fa74034609795df40f /gnu/usr.bin/perl/ext/Sys/Syslog/t/constants.t
parentf5f84f19259933187f80faf71c3c9c482a4867e6 (diff)
perl 5.8.8 import
Diffstat (limited to 'gnu/usr.bin/perl/ext/Sys/Syslog/t/constants.t')
-rwxr-xr-xgnu/usr.bin/perl/ext/Sys/Syslog/t/constants.t41
1 files changed, 41 insertions, 0 deletions
diff --git a/gnu/usr.bin/perl/ext/Sys/Syslog/t/constants.t b/gnu/usr.bin/perl/ext/Sys/Syslog/t/constants.t
new file mode 100755
index 00000000000..d7c7b0c7dfe
--- /dev/null
+++ b/gnu/usr.bin/perl/ext/Sys/Syslog/t/constants.t
@@ -0,0 +1,41 @@
+#!/usr/bin/perl -T
+use strict;
+use File::Spec;
+use Test::More;
+
+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;
+
+my $callpack = my $testpack = 'Sys::Syslog';
+eval "use $callpack";
+
+eval "${callpack}::This()";
+like( $@, "/^This is not a valid $testpack macro/", "trying a non-existing macro");
+
+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) {
+ SKIP: {
+ $name =~ /^(\w+)$/ or skip "invalid name '$name'", 2;
+ $name = $1;
+ my $v = eval "${callpack}::$name()";
+
+ if(defined($v) && $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
+ }
+ }
+ }
+}