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

📄 250_ping_hires.t

📁 source of perl for linux application,
💻 T
字号:
# Test to make sure hires feature works.BEGIN {  if ($ENV{PERL_CORE}) {    unless ($ENV{PERL_TEST_Net_Ping}) {      print "1..0 # Skip: network dependent test\n";        exit;    }    chdir 't' if -d 't';    @INC = qw(../lib);  }  unless (eval "require Socket") {    print "1..0 \# Skip: no Socket\n";    exit;  }  unless (eval "require Time::HiRes") {    print "1..0 \# Skip: no Time::HiRes\n";    exit;  }  unless (getservbyname('echo', 'tcp')) {    print "1..0 \# Skip: no echo port\n";    exit;  }}use Test qw(plan ok $TESTERR);use Net::Ping;plan tests => 8;# Everything loaded fineok 1;my $p = new Net::Ping "tcp";# new() worked?ok !!$p;# Default is to not use Time::HiResok !$Net::Ping::hires;# Enable hires$p -> hires();ok $Net::Ping::hires;# Make sure disable works$p -> hires(0);ok !$Net::Ping::hires;# Enable again$p -> hires(1);ok $Net::Ping::hires;# Test on the default portmy ($ret, $duration) = $p -> ping("localhost");# localhost should always be reachable, right?ok $ret;# It is extremely likely that the duration contains a decimal# point if Time::HiRes is functioning properly, except when it# is fast enough to be "0", or slow enough to be exactly "1".if (! ok($duration =~ /\.|^[01]$/)) {    print($TESTERR "# duration=[$duration]\n");}

⌨️ 快捷键说明

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