Update Porting/release_managers_guide.pod and Porting/makerel
[p5sagit/p5-mst-13.2.git] / cpan / Sys-Syslog / t / constants.t
CommitLineData
a650b841 1#!perl -wT
8168e71f 2use strict;
04f98b29 3use File::Spec;
8168e71f 4use Test::More;
8168e71f 5
a8a27574 6# NB. For PERL_CORE to be set, taint mode must not be enabled
7fee2b4c 7my $macrosall = $ENV{PERL_CORE} ? File::Spec->catfile(qw(.. ext Sys-Syslog macros.all))
04f98b29 8 : 'macros.all';
9open(MACROS, $macrosall) or plan skip_all => "can't read '$macrosall': $!";
10my @names = map {chomp;$_} <MACROS>;
11close(MACROS);
12plan tests => @names * 2 + 2;
8168e71f 13
04f98b29 14my $callpack = my $testpack = 'Sys::Syslog';
15eval "use $callpack";
8168e71f 16
04f98b29 17eval "${callpack}::This()";
18like( $@, "/^This is not a valid $testpack macro/", "trying a non-existing macro");
8168e71f 19
04f98b29 20eval "${callpack}::NOSUCHNAME()";
21like( $@, "/^NOSUCHNAME is not a valid $testpack macro/", "trying a non-existing macro");
8168e71f 22
23# Testing all macros
24if(@names) {
25 for my $name (@names) {
04f98b29 26 SKIP: {
27 $name =~ /^(\w+)$/ or skip "invalid name '$name'", 2;
28 $name = $1;
29 my $v = eval "${callpack}::$name()";
30
6e4ef777 31 if(defined $v and $v =~ /^\d+$/) {
04f98b29 32 is( $@, '', "calling the constant $name as a function" );
33 like( $v, '/^\d+$/', "checking that $name is a number ($v)" );
34
35 } else {
36 like( $@, "/^Your vendor has not defined $testpack macro $name/",
37 "calling the constant via its name" );
38 skip "irrelevant test in this case", 1
39 }
40 }
8168e71f 41 }
42}