Sha256: d8cdd89f554c23017e2db9438e5394cc79e4b376f614b04d7cf985c1171bb3ea

Contents?: true

Size: 1.19 KB

Versions: 3

Compression:

Stored size: 1.19 KB

Contents

#
# Testing Ruote (OpenWFEru)
#
# Mon Jun 29 22:29:15 JST 2009
#

require File.join(File.dirname(__FILE__), 'base')


class EftLoopTest < Test::Unit::TestCase
  include FunctionalBase

  def test_loop

    pdef = Ruote.process_definition :name => 'test' do
      _loop do
        alpha
        bravo
      end
    end

    #noisy

    @engine.register_participant :alpha do |workitem|

      @tracer << "a\n"
      (workitem.fields['count'] ||= 0)
      workitem.fields['count'] += 1
    end

    @engine.register_participant :bravo do |workitem|

      @tracer << "b\n"
      workitem.fields['count'] += 1

      workitem.fields['__command__'] = [ 'break', nil ] \
        if workitem.fields['count'] > 5
    end

    assert_trace(pdef, %w[ a b a b a b ])
  end

  def test_repeat

    pdef = Ruote.process_definition :name => 'test' do
      repeat do
        alpha
      end
    end

    #noisy

    @engine.register_participant :alpha do |workitem|

      @tracer << "a\n"
      (workitem.fields['count'] ||= 0)
      workitem.fields['count'] += 1

      workitem.fields['__command__'] = [ 'break', nil ] \
        if workitem.fields['count'] > 5
    end

    assert_trace(pdef, %w[ a a a a a a ])
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ruote-2.1.3 test/functional/eft_15_loop.rb
ruote-2.1.2 test/functional/eft_15_loop.rb
ruote-2.1.1 test/functional/eft_15_loop.rb