Sha256: 9a21e7934b67c65bdd7298ee93c87df9f81e49d0d2b2a31b51437cff75f0c12b

Contents?: true

Size: 1.2 KB

Versions: 9

Compression:

Stored size: 1.2 KB

Contents

  #  _____         _
  # |_   _|__  ___| |_
  #   | |/ _ \/ __| __|
  #   | |  __/\__ \ |
  #   |_|\___||___/\__|
  #
  # for lib/facets/coroutine.rb
  #
  # Extracted Mon Sep 03 16:23:07 -0700 2007
  # w/ Test Extraction Ratchet
  #

 require 'facets/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

9 entries across 9 versions & 1 rubygems

Version Path
facets-2.0.1 test/unit/test_coroutine.rb
facets-2.0.0 test/unit/test_coroutine.rb
facets-2.0.2 test/unit/test_coroutine.rb
facets-2.0.4 test/unit/test_coroutine.rb
facets-2.1.0 test/unit/test_coroutine.rb
facets-2.1.1 test/unit/test_coroutine.rb
facets-2.1.2 test/unit/test_coroutine.rb
facets-2.0.5 test/unit/test_coroutine.rb
facets-2.0.3 test/unit/test_coroutine.rb