<commit_before>
#
# Testing Ruote (OpenWFEru)
#
# Thu Jun 18 11:03:45 JST 2009
#

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


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

  def test_wait_for

    pdef = Ruote.process_definition do
      sequence do
        alpha
        wait :for => '1s'
        alpha
      end
    end

    #noisy

    ts = []

    @engine.register_participant :alpha do
      ts << Time.now
    end

    @engine.launch(pdef)

    sleep 1.6

    #p ts
    assert ts[1] - ts[0] > 1.0
  end

  def test_cancel_wait

    pdef = Ruote.process_definition do
      sequence do
        echo 'a'
        wait :for => '3d'
        echo 'b'
      end
    end

    #noisy

    wfid = @engine.launch(pdef)

    sleep 0.300

    @engine.cancel_process(wfid)

    wait_for(wfid)

    assert_equal 'a', @tracer.to_s
    assert_equal 0, @engine.scheduler.jobs.size
  end

  def test_wait_for_number

    pdef = Ruote.process_definition do
      sequence do
        echo 'a'
        wait 0.500
        echo 'b'
      end
    end

    assert_trace pdef, %w[ a b ]
  end
end
<commit_msg>wait : added test for wait :until => t<commit_after>
#
# Testing Ruote (OpenWFEru)
#
# Thu Jun 18 11:03:45 JST 2009
#

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


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

  def test_wait_for

    pdef = Ruote.process_definition do
      sequence do
        alpha
        wait :for => '1s'
        alpha
        echo 'done.'
      end
    end

    #noisy

    ts = []
    @engine.register_participant(:alpha) { ts << Time.now }

    assert_trace pdef, 'done.'

    #p ts
    assert ts[1] - ts[0] > 1.0
  end

  def test_cancel_wait

    pdef = Ruote.process_definition do
      sequence do
        echo 'a'
        wait :for => '3d'
        echo 'b'
      end
    end

    #noisy

    wfid = @engine.launch(pdef)

    sleep 0.300

    @engine.cancel_process(wfid)

    wait_for(wfid)

    assert_equal 'a', @tracer.to_s
    assert_equal 0, @engine.scheduler.jobs.size
  end

  def test_wait_for_number

    pdef = Ruote.process_definition do
      sequence do
        echo 'a'
        wait 0.500
        echo 'b'
      end
    end

    assert_trace pdef, %w[ a b ]
  end

  def test_wait_until

    pdef = Ruote.process_definition do
      sequence do
        alpha
        wait :until => (Time.now + 2.0).to_s
        alpha
        echo 'done.'
      end
    end

    #noisy

    ts = []
    @engine.register_participant(:alpha) { ts << Time.now }

    assert_trace pdef, 'done.'

    #p ts
    assert ts[1] - ts[0] > 1.0
  end
end

{'fraction_non_alphanumeric': 0.0963302752293578, 'fraction_numerical': 0.023700305810397553, 'mean_word_length': 1.9272930648769575, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4488258', 'n_tokens_mistral': 1019, 'n_tokens_neox': 915, 'n_words': 241}