我有一个正在工作的 Coro 程序,我正在为其编写测试脚本
这是我尝试测试的简化版本
use Test::More ;#tests => 9;
BEGIN{
use_ok( 'EV' ) || print "Bail out!\n";
use_ok( 'Coro' ) || print "Bail out!\n";
use_ok( 'AnyEvent' ) || print "Bail out!\n";
use_ok( 'Coro::AnyEvent' ) || print "Bail out!\n";
}
my @coro;
push @coro, async sub{ok(Coro::AnyEvent::sleep(2), 'sleep')};
push @coro, async sub{ok (1 == 1, 'one equals one')};
push @coro, async sub{isnt (1, 2, 'one does not equal two')};
#push @coro, async sub{is(EV::unloop, undef, 'unloop')};
#EV::run;
map {ok($_->join, 'join')} @coro;
这给了我
t/coro-test.t ..
ok 1 - use EV;
ok 2 - use Coro;
ok 3 - use AnyEvent;
ok 4 - use Coro::AnyEvent;
ok 5 - one equals one
ok 6 - one does not equal two
Undefined subroutine &main:: called at /usr/lib/perl5/Coro/AnyEvent.pm line 218.
Dubious, test returned 9 (wstat 2304, 0x900)
All 6 subtests passed
Test Summary Report
-------------------
t/coro-test.t (Wstat: 2304 Tests: 6 Failed: 0)
Non-zero exit status: 9
Parse errors: No plan found in TAP output
Files=1, Tests=6, 0 wallclock secs ( 0.02 usr 0.01 sys + 0.18 cusr 0.03 csys = 0.24 CPU)
Result: FAIL
我的(真实的)程序关闭了协程,然后他们就睡着了,他们无事可做,所以这不是一个人为的例子。
感激地收到任何帮助。(我认为 unloop 和 EV::run 不是必需的)