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

📄 err.t

📁 source of perl for linux application,
💻 T
字号:
use strict;use warnings;BEGIN {    if ($ENV{'PERL_CORE'}){        chdir 't';        unshift @INC, '../lib';    }    require($ENV{PERL_CORE} ? "./test.pl" : "./t/test.pl");    use Config;    if (! $Config{'useithreads'}) {        skip_all(q/Perl not compiled with 'useithreads'/);    }    plan(10);}use ExtUtils::testlib;use_ok('threads');### Start of Testing ###no warnings 'threads';# Create a thread that generates an errormy $thr = threads->create(sub { my $x = Foo->new(); });# Check that thread returns 'undef'my $result = $thr->join();ok(! defined($result), 'thread died');# Check errorlike($thr->error(), q/Can't locate object method/, 'thread error');# Create a thread that 'die's with an object$thr = threads->create(sub {                    threads->yield();                    sleep(1);                    die(bless({ error => 'bogus' }, 'Err::Class'));                });my $err = $thr->error();ok(! defined($err), 'no error yet');# Check that thread returns 'undef'$result = $thr->join();ok(! defined($result), 'thread died');# Check that error object is retrieved$err = $thr->error();isa_ok($err, 'Err::Class', 'error object');is($err->{error}, 'bogus', 'error field');# Check that another thread can reference the error objectmy $thrx = threads->create(sub { die(bless($thr->error(), 'Foo')); });# Check that thread returns 'undef'$result = $thrx->join();ok(! defined($result), 'thread died');# Check that the rethrown error object is retrieved$err = $thrx->error();isa_ok($err, 'Foo', 'error object');is($err->{error}, 'bogus', 'error field');# EOF

⌨️ 快捷键说明

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