Sha256: 821372b34d7aa04668c862067c1fb08ab3f227703ceeeddbc2280f60f26bc1d4

Contents?: true

Size: 1.19 KB

Versions: 1

Compression:

Stored size: 1.19 KB

Contents

#  _____         _
# |_   _|__  ___| |_
#   | |/ _ \/ __| __|
#   | |  __/\__ \ |_
#   |_|\___||___/\__|
#
# for lib/facets/more/coroutine.rb
#
# Extracted Tue Jul 25 10:07:15 EDT 2006
# Unit Tools Reap Test Extractor
#

require 'facets/more/coroutine.rb'


  require 'test/unit'

  class TC_Coroutine < Test::Unit::TestCase

    def test_run
      assert_nothing_raised {

        count = 100
        input = (1..count).map { (rand * 10000).round.to_f / 100 }

        @producer = Coroutine.new do |me|
          loop do
            1.upto(6) do
              me[:last_input] = input.shift
              me.resume(@printer)
            end
            input.shift  # discard every seventh input number
          end
        end

        @printer = Coroutine.new do |me|
          loop do
            1.upto(8) do
              me.resume(@producer)
              if @producer[:last_input]
                @producer[:last_input] = nil
              end
              me.resume(@controller)
            end
          end
        end

        @controller = Coroutine.new do |me|
          until input.empty? do
            me.resume(@printer)
          end
        end
        @controller.run

      }
    end

  end


Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
facets-1.7.0 test/lib/facets/more/test_coroutine.rb