diff options
author | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-12-23 10:18:58 +0000 |
---|---|---|
committer | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-12-23 10:18:58 +0000 |
commit | 0f9b33c793f225c1b817d73e5c915050c429edc4 (patch) | |
tree | 9df2ce83ba36c8d714eae9d3362f0dca23520ee8 /test | |
parent | 80b55686f0cce9c8fb2aaec6e5f957555e18f60c (diff) | |
download | ruby-0f9b33c793f225c1b817d73e5c915050c429edc4.tar.gz |
* thread.c: rename methods:
from Thread.async_interrupt_timing to Thread.handle_interrupt,
from Thread.async_interrupted? to Thread.pending_interrupt?.
Also rename option from `defer' to `never'.
[ruby-core:51074] [ruby-trunk - Feature #6762]
* vm_core.c, thread.c: rename functions and data structure
`async_errinfo' to `pending_interrupt'.
* thread.c: add global variables sym_immediate, sym_on_blocking and
sym_never.
* cont.c, process.c, vm.c, signal.c: ditto.
* lib/sync.rb, lib/thread.rb: catch up this renaming.
* test/ruby/test_thread.rb: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38577 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_thread.rb | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/test/ruby/test_thread.rb b/test/ruby/test_thread.rb index b297d68fdc..52e6d67560 100644 --- a/test/ruby/test_thread.rb +++ b/test/ruby/test_thread.rb @@ -516,12 +516,12 @@ class TestThread < Test::Unit::TestCase assert_equal("Can't call on top of Fiber or Thread", error.message, bug5083) end - def make_async_interrupt_timing_test_thread1 flag + def make_handle_interrupt_test_thread1 flag r = [] ready_p = false th = Thread.new{ begin - Thread.async_interrupt_timing(RuntimeError => flag){ + Thread.handle_interrupt(RuntimeError => flag){ begin ready_p = true sleep 0.5 @@ -543,46 +543,46 @@ class TestThread < Test::Unit::TestCase r end - def test_async_interrupt_timing - [[:defer, :c2], + def test_handle_interrupt + [[:never, :c2], [:immediate, :c1], [:on_blocking, :c1]].each{|(flag, c)| - assert_equal([flag, c], [flag] + make_async_interrupt_timing_test_thread1(flag)) + assert_equal([flag, c], [flag] + make_handle_interrupt_test_thread1(flag)) } # TODO: complex cases are needed. end - def test_async_interrupt_timing_invalid_argument + def test_handle_interrupt_invalid_argument assert_raise(ArgumentError) { - Thread.async_interrupt_timing(RuntimeError => :immediate) # no block + Thread.handle_interrupt(RuntimeError => :immediate) # no block } assert_raise(ArgumentError) { - Thread.async_interrupt_timing(RuntimeError => :never) {} # never? + Thread.handle_interrupt(RuntimeError => :xyzzy) {} } assert_raise(TypeError) { - Thread.async_interrupt_timing([]) {} # array + Thread.handle_interrupt([]) {} # array } end - def for_test_async_interrupt_with_return - Thread.async_interrupt_timing(Object => :defer){ + def for_test_handle_interrupt_with_return + Thread.handle_interrupt(Object => :never){ Thread.current.raise RuntimeError.new("have to be rescured") return } rescue end - def test_async_interrupt_with_return + def test_handle_interrupt_with_return assert_nothing_raised do - for_test_async_interrupt_with_return + for_test_handle_interrupt_with_return _dummy_for_check_ints=nil end end - def test_async_interrupt_with_break + def test_handle_interrupt_with_break assert_nothing_raised do begin - Thread.async_interrupt_timing(Object => :defer){ + Thread.handle_interrupt(Object => :never){ Thread.current.raise RuntimeError.new("have to be rescured") break } @@ -592,13 +592,13 @@ class TestThread < Test::Unit::TestCase end end - def test_async_interrupt_blocking + def test_handle_interrupt_blocking r=:ng e=Class.new(Exception) th_s = Thread.current begin th = Thread.start{ - Thread.async_interrupt_timing(Object => :on_blocking){ + Thread.handle_interrupt(Object => :on_blocking){ begin Thread.current.raise RuntimeError r=:ok @@ -617,12 +617,12 @@ class TestThread < Test::Unit::TestCase assert_equal(:ok,r) end - def test_async_interrupt_and_io + def test_handle_interrupt_and_io assert_in_out_err([], <<-INPUT, %w(ok), []) th_waiting = true t = Thread.new { - Thread.async_interrupt_timing(RuntimeError => :on_blocking) { + Thread.handle_interrupt(RuntimeError => :on_blocking) { nil while th_waiting # async interrupt should be raised _before_ writing puts arguments puts "ng" @@ -637,12 +637,12 @@ class TestThread < Test::Unit::TestCase INPUT end - def test_async_interrupt_and_p + def test_handle_interrupt_and_p assert_in_out_err([], <<-INPUT, %w(:ok :ok), []) th_waiting = true t = Thread.new { - Thread.async_interrupt_timing(RuntimeError => :on_blocking) { + Thread.handle_interrupt(RuntimeError => :on_blocking) { nil while th_waiting # p shouldn't provide interruptible point p :ok @@ -657,9 +657,9 @@ class TestThread < Test::Unit::TestCase INPUT end - def test_async_interrupted? + def test_handle_interrupted? q = Queue.new - Thread.async_interrupt_timing(RuntimeError => :defer){ + Thread.handle_interrupt(RuntimeError => :never){ th = Thread.new{ q.push :e begin @@ -669,7 +669,7 @@ class TestThread < Test::Unit::TestCase q.push :ng1 end begin - Thread.async_interrupt_timing(Object => :immediate){} if Thread.async_interrupted? + Thread.handle_interrupthandle_interrupt(Object => :immediate){} if Thread.pending_interrupt? rescue => e q.push :ok end |