01_list.t

来自「source of perl for linux application,」· T 代码 · 共 53 行

T
53
字号
use strict;use Test::More 'no_plan';BEGIN { chdir 't' if -d 't' };use lib '../lib';my $Class   = 'Package::Constants';my $Func    = 'list';my $Pkg     = '_test';my @Good    = 'A'..'C';my @Bad     = 'D'..'E';use_ok( $Class );can_ok( $Class, $Func );### enable debug statements?$Package::Constants::DEBUG = $Package::Constants::DEBUG = @ARGV ? 1 : 0;### small test class {   package _test;    ### mark us as loaded    $INC{'_test.pm'} = $0;        use vars qw[$FOO];    $FOO = 1;        ### define various subs.. the first 3 are constants,     ### the others are not    use constant A => 1;    use constant B => sub { 1 };    sub C ()        { 1 };        sub D           { 1 };    sub E (*)       { 1 };}    ### get the list{   my @list = $Class->$Func( $Pkg );    ok( scalar(@list),          "Got a list of constants" );    is_deeply( \@list, \@Good,  "   Contains all expected entries" );}    # Local variables:# c-indentation-style: bsd# c-basic-offset: 4# indent-tabs-mode: nil# End:# vim: expandtab shiftwidth=4:

⌨️ 快捷键说明

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