Sha256: 073a959d352376e96fe7282f42fb8dee3c0d90954a1c88ee091adf955a6e8452

Contents?: true

Size: 1.17 KB

Versions: 4

Compression:

Stored size: 1.17 KB

Contents

#
# testing ruote
#
# 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

4 entries across 4 versions & 1 rubygems

Version Path
ruote-2.1.7 test/functional/eft_15_loop.rb
ruote-2.1.6 test/functional/eft_15_loop.rb
ruote-2.1.5 test/functional/eft_15_loop.rb
ruote-2.1.4 test/functional/eft_15_loop.rb