stas 2002/06/14 03:06:16 Modified: t/protocol eliza.t t/protocol/TestProtocol eliza.pm Log: - test that Eliza has actually closed the loop - adjust the eliza handler to work over the telnet client as well, where \r is sent instead of \n Revision Changes Path 1.5 +9 -2 modperl-2.0/t/protocol/eliza.t Index: eliza.t =================================================================== RCS file: /home/cvs/modperl-2.0/t/protocol/eliza.t,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- eliza.t 22 May 2002 19:43:45 -0000 1.4 +++ eliza.t 14 Jun 2002 10:06:16 -0000 1.5 @@ -11,7 +11,7 @@ 'I feel like writing some tests today, what about you?', 'Good bye, Eliza'); -plan tests => 1 + @test_strings, have_module 'Chatbot::Eliza'; +plan tests => 2 + @test_strings, have_module 'Chatbot::Eliza'; my $socket = Apache::TestRequest::vhost_socket('TestProtocol::eliza'); @@ -19,8 +19,15 @@ for (@test_strings) { print $socket "$_\n"; - chomp(my $reply = <$socket>); + chomp(my $reply = <$socket> || ''); t_debug "send: $_"; t_debug "recv: $reply"; ok $reply; } + +# at this point 'Good bye, Eliza' should abort the connection. +my $string = 'Eliza should not hear this'; +print $socket "$string\n"; +chomp(my $reply = <$socket> || ''); +t_debug "Eliza shouldn't respond anymore"; +ok !$reply; 1.5 +4 -2 modperl-2.0/t/protocol/TestProtocol/eliza.pm Index: eliza.pm =================================================================== RCS file: /home/cvs/modperl-2.0/t/protocol/TestProtocol/eliza.pm,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- eliza.pm 22 May 2002 19:49:28 -0000 1.4 +++ eliza.pm 14 Jun 2002 10:06:16 -0000 1.5 @@ -25,8 +25,10 @@ $rlen = BUFF_LEN; $socket->recv($buff, $rlen); last if $rlen <= 0; - chomp $buff; - $last++ if $buff eq 'Good bye, Eliza'; + + # \r is sent instead of \n if the client is talking over telnet + $buff =~ s/[\r\n]*$//; + $last++ if $buff eq "Good bye, Eliza"; $buff = $mybot->transform( $buff ) . "\n"; $socket->send($buff, length $buff); last if $last;