diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-05-28 03:05:48 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-05-28 03:05:48 +0000 |
commit | bd77dbc37a2f77c67162065359d39c25e6d4ded7 (patch) | |
tree | d6d083f602bf34b99e51343b2fcf05900db8413e | |
parent | 11422497134555d738e34f1d9d6c7fcc98a0f592 (diff) | |
download | ruby-bd77dbc37a2f77c67162065359d39c25e6d4ded7.tar.gz |
test_thread.rb: move thread switch test
* test/ruby/test_thread.rb (test_switch_while_busy_loop): move
from test/test_timeout.rb. [Bug #1402]
* test/test_timeout.rb (test_timeout): no longer related to
[Bug #1402]. [Bug #8523]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46196 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | test/ruby/test_thread.rb | 18 | ||||
-rw-r--r-- | test/test_timeout.rb | 10 |
2 files changed, 20 insertions, 8 deletions
diff --git a/test/ruby/test_thread.rb b/test/ruby/test_thread.rb index 213b1f908e..6701d10226 100644 --- a/test/ruby/test_thread.rb +++ b/test/ruby/test_thread.rb @@ -369,6 +369,24 @@ class TestThread < Test::Unit::TestCase c.kill if c end + def test_switch_while_busy_loop + bug1402 = "[ruby-dev:38319] [Bug #1402]" + flag = true + th = Thread.current + waiter = Thread.start { + sleep 0.1 + flag = false + sleep 1 + th.raise(bug1402) + } + assert_nothing_raised(RuntimeError, bug1402) do + nil while flag + end + assert(!flag, bug1402) + ensure + waiter.kill.join + end + def test_safe_level ok = false t = Thread.new do diff --git a/test/test_timeout.rb b/test/test_timeout.rb index e350762637..e71a09f22c 100644 --- a/test/test_timeout.rb +++ b/test/test_timeout.rb @@ -11,17 +11,11 @@ class TestTimeout < Test::Unit::TestCase end def test_timeout - flag = true - Thread.start { - sleep 1 - flag = false - } - assert_raise(Timeout::Error, "[ruby-dev:38319]") do + assert_raise(Timeout::Error) do Timeout.timeout(0.1) { - Thread.pass while flag + nil while true } end - assert flag, "[ruby-dev:38319]" end def test_cannot_convert_into_time_interval |