testutil.pl

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

PL
49
字号
{  my $__ntest;  my $__total;  sub plan {    @_ == 2 or die "usage: plan(tests => count)";    my $what = shift;    $what eq 'tests' or die "cannot plan anything but tests";    $__total = shift;    defined $__total && $__total > 0 or die "need a positive number of tests";    print "1..$__total\n";  }  sub skip {    my $reason = shift;    ++$__ntest;    print "ok $__ntest # skip: $reason\n"  }  sub ok ($;$$) {    local($\,$,);    my $ok = 0;    my $result = shift;    if (@_ == 0) {      $ok = $result;    } else {      $expected = shift;      if (!defined $expected) {        $ok = !defined $result;      } elsif (!defined $result) {        $ok = 0;      } elsif (ref($expected) eq 'Regexp') {        die "using regular expression objects is not backwards compatible";      } else {        $ok = $result eq $expected;      }    }    ++$__ntest;    if ($ok) {      print "ok $__ntest\n"    }    else {      print "not ok $__ntest\n"    }  }}1;

⌨️ 快捷键说明

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