Sha256: 0ecd85427a9eba7504c326e50ea887450f06e1251478c94e3220ce809afb6797

Contents?: true

Size: 1004 Bytes

Versions: 17

Compression:

Stored size: 1004 Bytes

Contents

# Test facets/timer.rb

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

17 entries across 17 versions & 1 rubygems

Version Path
facets-2.8.4 test/more/test_timer.rb
facets-2.8.3 test/more/test_timer.rb
facets-2.8.2 test/more/test_timer.rb
facets-2.8.1 test/more/test_timer.rb
facets-2.8.0 test/more/test_timer.rb
facets-2.7.0 test/more/test_timer.rb
facets-2.6.0 test/more/test_timer.rb
facets-2.4.0 test/test_timer.rb
facets-2.3.0 test/class/test_timer.rb
facets-2.4.1 test/test_timer.rb
facets-2.4.2 test/more/test_timer.rb
facets-2.4.4 test/more/test_timer.rb
facets-2.4.3 test/more/test_timer.rb
facets-2.4.5 test/more/test_timer.rb
facets-2.5.1 test/more/test_timer.rb
facets-2.5.0 test/more/test_timer.rb
facets-2.5.2 test/more/test_timer.rb