1 # File: Stem/Test/Flow.pm
3 # This file is part of Stem.
4 # Copyright (C) 1999, 2000, 2001 Stem Systems, Inc.
6 # Stem is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # Stem is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with Stem; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 # For a license to use the Stem under conditions other than those
21 # described here, to purchase support for this software, or to purchase a
22 # commercial warranty contract, please contact Stem Systems at:
24 # Stem Systems, Inc. 781-643-7504
25 # 79 Everett St. info@stemsystems.com
29 package Stem::Test::Flow ;
31 use Test::More tests => 30 ;
33 use base 'Stem::Cell' ;
40 This is the name under which this Cell was registered.
45 'class' => 'Stem::Cell',
46 'name' => 'cell_attr',
48 This value is the attributes for the included Stem::Cell which handles
49 cloning, async I/O and pipes.
57 my( $class ) = shift ;
59 my $self = Stem::Class::parse_args( $attr_spec, @_ ) ;
60 return $self unless ref $self ;
62 my $flow_text = <<FLOW ;
120 delay delay_set( 2 ) ;
130 $self->cell_flow_init( 'test', $flow_text ) ;
132 $self->cell_flow_go_in() ;
138 ok(1, 'plain method') ;
143 my( $self, $arg1, $arg2 ) = @_ ;
144 ok( $arg1 ==1 && $arg2 eq 'a', 'methods with args' ) ;
149 ok(1, 'if condition') ;
154 ok(1, 'method in block' ) ;
159 ok(0, 'then block was called' ) ;
166 ok(1, 'while condition') ;
167 return 1 if $w1++ < 2 ;
173 ok(1, 'method in while' ) ;
181 ok(1, 'until condition') ;
186 ok(1, 'unless condition') ;
191 ok(1, 'method in unless' ) ;
198 ok(1, 'method in else' ) ;
206 ok(1, 'outer while condition') ;
207 return 1 if $w3++ < 1 ;
215 ok(1, 'inner while condition') ;
216 return 1 if $w4++ < 1 ;
232 ok(1, 'while condition') ;
233 return 1 if $w1++ < 1 ;
266 my( $self, $delta ) = @_ ;
272 #print "$time $delay_time\n" ;
274 ok( $time - $delay_time >= $delta, 'delay done' ) ;
282 my( $self, $delay ) = @_ ;
284 ok( 1, 'delay set method' ) ;
293 ok(1, 'message method' ) ;
295 my $msg = Stem::Msg->new( to => $self->{'reg_name'},
296 from => $self->{'reg_name'},
300 #print $msg->dump( 'MSG1' ) ;
308 my ( $self, $msg ) = @_ ;
310 #print $msg->dump( 'FLOW' ) ;
311 ok(1, 'flow message in' ) ;
313 my $reply = $msg->reply() ;
315 #print $reply->dump( 'reply' ) ;
324 my ( $self, $msg ) = @_ ;
326 ok(1, 'message received' ) ;
328 #print $msg->dump( 'GET' ) ;
334 ok(1, 'exit method' ) ;