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

- old
+ new

@@ -14,21 +14,15 @@ include FunctionalBase class CountingParticipant include Ruote::LocalParticipant - attr_reader :wfids + def consume(workitem) - def initialize + @context.stash[:wfids] ||= [] + @context.stash[:wfids] << "#{workitem.fei.wfid}|#{workitem.fei.subid}" - @wfids = [] - end - - def consume (workitem) - - @wfids << "#{workitem.fei.wfid}|#{workitem.fei.sub_wfid}" - workitem.fields['count'] ||= 0 workitem.fields['count'] = workitem.fields['count'] + 1 @context.tracer << workitem.fields['count'].to_s + "\n" @@ -37,55 +31,57 @@ else reply_to_engine(workitem) end end - def cancel (fei, flavour) + def cancel(fei, flavour) end end def test_main_recursion + @engine.context.stash[:wfids] = [] + pdef = Ruote.process_definition :name => 'def0' do sequence do alpha def0 end end - alpha = @engine.register_participant :alpha, CountingParticipant.new + alpha = @engine.register_participant :alpha, CountingParticipant #noisy assert_trace(%w[ 1 2 3 4 5 6 ], pdef) - #p alpha.wfids.uniq - - assert_equal 6, alpha.wfids.uniq.size + assert_equal 6, @engine.context.stash[:wfids].uniq.size end def test_sub_recursion + @engine.context.stash[:wfids] = [] + pdef = Ruote.process_definition do define 'sub0' do sequence do alpha sub0 end end sub0 end - alpha = @engine.register_participant :alpha, CountingParticipant.new + alpha = @engine.register_participant :alpha, CountingParticipant #noisy assert_trace %w[ 1 2 3 4 5 6 ], pdef #p alpha.wfids.uniq - assert_equal 6, alpha.wfids.uniq.size + assert_equal 6, @engine.context.stash[:wfids].uniq.size end def test_forgotten_main_recursion pdef = Ruote.process_definition :name => 'def0' do @@ -95,10 +91,10 @@ def0 end end end - alpha = @engine.register_participant :alpha, CountingParticipant.new + alpha = @engine.register_participant :alpha, CountingParticipant #noisy wfid = @engine.launch(pdef)