test/functional/eft_14_cursor.rb in ruote-2.1.11 vs test/functional/eft_14_cursor.rb in ruote-2.2.0

- old
+ new

@@ -83,10 +83,25 @@ #noisy assert_trace('a', pdef) end + def test_over + + pdef = Ruote.process_definition :name => 'test' do + cursor do + echo 'a' + over + echo 'b' + end + end + + #noisy + + assert_trace('a', pdef) + end + def test_jump_to_tag pdef = Ruote.process_definition :name => 'test' do cursor do echo 'a' @@ -152,20 +167,18 @@ jump :to => 'author', :if => '${not_ok}' publisher end end - count = 0 - # closures ftw - @engine.register_participant :author do |workitem| @tracer << "a\n" - count = count + 1 + stash[:count] ||= 0 + stash[:count] += 1 end @engine.register_participant :reviewer do |workitem| @tracer << "r\n" - workitem.fields['not_ok'] = (count < 3) + workitem.fields['not_ok'] = (stash[:count] < 3) end @engine.register_participant :publisher do |workitem| @tracer << "p\n" end @@ -211,11 +224,11 @@ alpha end end end - @engine.register_participant :alpha, Ruote::NoOpParticipant.new + @engine.register_participant :alpha, Ruote::NoOpParticipant #noisy wfid = @engine.launch(pdef) @@ -275,19 +288,19 @@ assert_trace 'done.', pdef end class Alpha include Ruote::LocalParticipant - def consume (workitem) + def consume(workitem) workitem.command = 'break' reply_to_engine(workitem) end - def cancel (fei, flavour) + def cancel(fei, flavour) end end class Bravo < Alpha - def consume (workitem) + def consume(workitem) workitem.command = 'skip 1' reply_to_engine(workitem) end end @@ -310,8 +323,84 @@ alpha EftCursorTest::Alpha bravo EftCursorTest::Bravo end assert_trace "in\ndone.", pdef + end + + def test_cursor_with_lonely_rewind + + pdef = Ruote.define do + cursor do + rewind + end + end + + #@engine.noisy = true + + wfid = @engine.launch(pdef) + + @engine.wait_for(9) + + assert_not_nil @engine.process(wfid) + end + + class Charly + include Ruote::LocalParticipant + def initialize(opts) + @opts = opts + end + def consume(workitem) + workitem.command = @opts['command'] + reply_to_engine(workitem) + end + def cancel(fei, flavour) + end + end + + JUMP_DEF = Ruote.process_definition do + cursor do + echo 'top' + charly + echo 'middle' + delta + echo 'bottom' + end + end + + def test_workitem_command_and_jump_array + + #noisy + + @engine.register do + charly EftCursorTest::Charly, 'command' => [ 'jump', 'delta' ] + catchall Ruote::NoOpParticipant + end + + assert_trace "top\nbottom", JUMP_DEF + end + + def test_workitem_command_and_jump_string + + #noisy + + @engine.register do + charly EftCursorTest::Charly, 'command' => 'jump delta' + catchall Ruote::NoOpParticipant + end + + assert_trace "top\nbottom", JUMP_DEF + end + + def test_workitem_command_and_jump_to_string + + #noisy + + @engine.register do + charly EftCursorTest::Charly, 'command' => 'jump to delta' + catchall Ruote::NoOpParticipant + end + + assert_trace "top\nbottom", JUMP_DEF end end