1*898184e3Ssthen#!perl 2*898184e3Ssthen 3*898184e3Ssthenuse Test::More; 4*898184e3Ssthen 5*898184e3Sstheneval "use AnyEvent; 1" or 6*898184e3Ssthen plan skip_all => "AnyEvent is not installed."; 7*898184e3Ssthen 8*898184e3Ssthen# seeing as the entire point of this test is to test the event handler, 9*898184e3Ssthen# we need to mock as little as possible. To keep things tightly controlled, 10*898184e3Ssthen# we'll use the Stub directly. 11*898184e3SsthenBEGIN { 12*898184e3Ssthen $ENV{PERL_RL} = 'Stub o=0'; 13*898184e3Ssthen} 14*898184e3Ssthenplan tests => 3; 15*898184e3Ssthen 16*898184e3Ssthen# need to delay this so that AE is loaded first. 17*898184e3Ssthenrequire Term::ReadLine; 18*898184e3Ssthenuse File::Spec; 19*898184e3Ssthen 20*898184e3Ssthenmy $t = Term::ReadLine->new('AE'); 21*898184e3Ssthenok($t, "Created object"); 22*898184e3Ssthenis($t->ReadLine, 'Term::ReadLine::Stub', 'Correct type'); 23*898184e3Ssthen 24*898184e3Ssthenmy ($cv, $fe); 25*898184e3Ssthen$t->event_loop( 26*898184e3Ssthen sub { 27*898184e3Ssthen $cv = AE::cv(); 28*898184e3Ssthen $cv->recv(); 29*898184e3Ssthen }, sub { 30*898184e3Ssthen my $fh = shift; 31*898184e3Ssthen $fe ||= AE::io($fh, 0, sub { $cv->send() }); 32*898184e3Ssthen } 33*898184e3Ssthen ); 34*898184e3Ssthen 35*898184e3Ssthenmy $text = 'some text'; 36*898184e3Ssthenmy $T = $text . "\n"; 37*898184e3Ssthenmy $w = AE::timer(0,1,sub { 38*898184e3Ssthenpass("Event loop called"); 39*898184e3Ssthenexit 0; 40*898184e3Ssthen}); 41*898184e3Ssthen 42*898184e3Ssthenmy $result = $t->readline('Do not press enter>'); 43*898184e3Ssthenfail("Should not get here."); 44