Sha256: fb70cf711ad06036c1f282a2b2d9337e0800350091f1cc3f64f60e0d966e6466

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(%w[ a b a b a b ], pdef)
  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(%w[ a a a a a a ], pdef)
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ruote-2.1.11 test/functional/eft_15_loop.rb
ruote-2.1.10 test/functional/eft_15_loop.rb
ruote-2.1.9 test/functional/eft_15_loop.rb
ruote-2.1.8 test/functional/eft_15_loop.rb