summaryrefslogtreecommitdiff
path: root/test/drb/ut_timerholder.rb
diff options
context:
space:
mode:
authorseki <seki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-05-15 11:59:00 +0000
committerseki <seki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-05-15 11:59:00 +0000
commite143a741913fd970e27eb83e3d809d9694038f9f (patch)
tree1e718e303e65eaad1ddce788dbc41cefa019d4bc /test/drb/ut_timerholder.rb
parent6b4132724aeb5cf25307a04fd7001065526873c9 (diff)
don't use keeper thread. [Bug #12342]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55008 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/drb/ut_timerholder.rb')
-rw-r--r--test/drb/ut_timerholder.rb70
1 files changed, 27 insertions, 43 deletions
diff --git a/test/drb/ut_timerholder.rb b/test/drb/ut_timerholder.rb
index 1b992d95f3b..252c7bd228b 100644
--- a/test/drb/ut_timerholder.rb
+++ b/test/drb/ut_timerholder.rb
@@ -1,54 +1,38 @@
# frozen_string_literal: false
-require 'runit/testcase'
-require 'runit/cui/testrunner'
-require 'timerholder'
+require 'test/unit'
+require 'drb/timeridconv'
module DRbTests
-class TimerHolderTest < RUNIT::TestCase
- def do_test(timeout, keeper_sleep = nil)
- holder = TimerHolder.new(timeout)
- holder.keeper_sleep = keeper_sleep if keeper_sleep
- key = holder.add(self)
- sleep(timeout * 0.5)
- assert_equal(holder.peek(key), self)
- holder.delete(key)
- assert(!holder.include?(key))
- key = holder.add(self)
- sleep(timeout+0.5)
- assert_equal(holder.fetch(key), nil)
- key = holder.add(self)
- assert_equal(holder.fetch(key), self)
- holder.store(key, true)
- assert_equal(holder.fetch(key), true)
- assert_equal(holder.include?(key), true)
- sleep(timeout+0.5)
- assert_exception(TimerHolder::InvalidIndexError) do
- holder.store(key, 1)
- end
- assert_equal(holder.include?(key), false)
- key = holder.add(self)
- sleep(timeout * 0.5)
- assert(holder.include?(key))
- holder.extend(key, timeout)
- sleep(timeout * 0.5)
- assert(holder.include?(key))
- sleep(timeout * 0.6)
- assert(!holder.include?(key))
- holder.delete(key)
- end
+class TimerIdConvTest < Test::Unit::TestCase
+ def test_usecase_01
+ keeping = 0.1
+ idconv = DRb::TimerIdConv.new(keeping)
- def test_00
- do_test(0.5)
- end
+ key = idconv.to_id(self)
+ assert_equal(key, self.__id__)
+ sleep(keeping)
+
+ assert_equal(idconv.to_id(false), false.__id__)
+ assert_equal(idconv.to_obj(key), self)
+ sleep(keeping)
+
+ assert_equal(idconv.to_obj(key), self)
+ sleep(keeping)
+
+ assert_equal(idconv.to_id(true), true.__id__)
+ sleep(keeping)
- def test_01
- do_test(1, 0.5)
+ assert_raise do
+ assert_equal(idconv.to_obj(key))
+ end
+
+ assert_raise do
+ assert_equal(idconv.to_obj(false.__id__))
+ end
end
end
-end
-if __FILE__ == $0
- RUNIT::CUI::TestRunner.run(DRbTests::TimerHolderTest.suite)
end
+