diff options
author | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2020-05-23 16:43:58 +0900 |
---|---|---|
committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2020-05-23 16:44:57 +0900 |
commit | d48c92aa04ffd3a1cecef599eaa5e4409aab2fe4 (patch) | |
tree | 3def7248473b54d9869031b5812509a12e61f484 /test/fiber/test_scheduler.rb | |
parent | 0b2fc4cf379dec82290c5bc9cc71ce8dc4e4f28b (diff) | |
download | ruby-d48c92aa04ffd3a1cecef599eaa5e4409aab2fe4.tar.gz |
Rename TestScheduler* to TestFiber for convention of the test directory
Diffstat (limited to 'test/fiber/test_scheduler.rb')
-rw-r--r-- | test/fiber/test_scheduler.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/test/fiber/test_scheduler.rb b/test/fiber/test_scheduler.rb new file mode 100644 index 0000000000..f3ea6e8ab6 --- /dev/null +++ b/test/fiber/test_scheduler.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true +require 'test/unit' +require_relative 'scheduler' + +class TestFiberScheduler < Test::Unit::TestCase + def test_fiber_without_scheduler + # Cannot create fiber without scheduler. + assert_raise RuntimeError do + Fiber do + end + end + end + + def test_fiber_blocking + scheduler = Scheduler.new + + thread = Thread.new do + Thread.current.scheduler = scheduler + + # Close is always a blocking operation. + IO.pipe.each(&:close) + end + + thread.join + + assert_not_empty scheduler.blocking + assert_match(/test_fiber\.rb:\d+:in `close'/, scheduler.blocking.last) + end +end |