Sha256: e41572e89112b6b1f256e3f680e2d706a129914e5f9f586620e4072bb0a15089

Contents?: true

Size: 1.19 KB

Versions: 9

Compression:

Stored size: 1.19 KB

Contents

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

 require 'facets/timer.rb'



require 'test/unit'

class TC_Timer < Test::Unit::TestCase

  def test_timed
    timed { |timer|
      assert_equal 0, timer.total_time.round
      sleep 1
      assert_equal 1, timer.total_time.round
      timer.stop
      assert_equal 1, timer.total_time.round
      sleep 1
      assert_equal 1, timer.total_time.round
      timer.start
      assert_equal 1, timer.total_time.round
      sleep 1
      assert_equal 2, timer.total_time.round
    }
  end

  def test_outoftime
    t = Timer.new(1)
    assert_raises( TimeoutError ) {
      t.start
      sleep 2
      t.stop
    }
  end

  # This has been removed becuase it is too close to call.
  # Sometimes and error is returned sometimes it is not.
  #def test_nickoftime
  #  assert_raises( TimeoutError ) {
  #    @t.start
  #    sleep 2
  #    @t.stop
  #  }
  #end

  def test_intime
    t = Timer.new(2)
    assert_nothing_raised {
      t.start
      sleep 1
      t.stop
    }
  end

end



Version data entries

9 entries across 9 versions & 1 rubygems

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