⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 constants.t

📁 source of perl for linux application,
💻 T
字号:
#!perl -wTuse strict;use File::Spec;use Test::More;# NB. For PERL_CORE to be set, taint mode must not be enabledmy $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 macrosif(@names) {    for my $name (@names) {        SKIP: {            $name =~ /^(\w+)$/ or skip "invalid name '$name'", 2;            $name = $1;            my $v = eval "${callpack}::$name()";            if(defined $v and $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            }        }    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -