Merge branch 'vincent/rvalue_stmt_given' into blead
[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
b5ffec61 7my $macrosall = 'macros.all';
04f98b29 8open(MACROS, $macrosall) or plan skip_all => "can't read '$macrosall': $!";
9my @names = map {chomp;$_} <MACROS>;
10close(MACROS);
11plan tests => @names * 2 + 2;
8168e71f 12
04f98b29 13my $callpack = my $testpack = 'Sys::Syslog';
14eval "use $callpack";
8168e71f 15
04f98b29 16eval "${callpack}::This()";
17like( $@, "/^This is not a valid $testpack macro/", "trying a non-existing macro");
8168e71f 18
04f98b29 19eval "${callpack}::NOSUCHNAME()";
20like( $@, "/^NOSUCHNAME is not a valid $testpack macro/", "trying a non-existing macro");
8168e71f 21
22# Testing all macros
23if(@names) {
24 for my $name (@names) {
04f98b29 25 SKIP: {
26 $name =~ /^(\w+)$/ or skip "invalid name '$name'", 2;
27 $name = $1;
28 my $v = eval "${callpack}::$name()";
29
6e4ef777 30 if(defined $v and $v =~ /^\d+$/) {
04f98b29 31 is( $@, '', "calling the constant $name as a function" );
32 like( $v, '/^\d+$/', "checking that $name is a number ($v)" );
33
34 } else {
35 like( $@, "/^Your vendor has not defined $testpack macro $name/",
36 "calling the constant via its name" );
37 skip "irrelevant test in this case", 1
38 }
39 }
8168e71f 40 }
41}