diff options
author | Samuel Williams <samuel.williams@oriontransfer.co.nz> | 2020-05-15 12:23:42 +1200 |
---|---|---|
committer | Samuel Williams <samuel.williams@oriontransfer.co.nz> | 2020-05-15 13:26:23 +1200 |
commit | 6fa8455ebbf457e5d8752295a8d6380146636c0c (patch) | |
tree | a5c16f9d9e386b78d16986fc00ed31cbc4bf56a7 /test/fiber/test_io.rb | |
parent | 39365b46e250162f278cb36aa148bc2a92b1b84a (diff) |
Move `test/scheduler` -> `test/fiber` [Bug #16892][ruby-core:98366].
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/3110
Diffstat (limited to 'test/fiber/test_io.rb')
-rw-r--r-- | test/fiber/test_io.rb | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/test/fiber/test_io.rb b/test/fiber/test_io.rb new file mode 100644 index 0000000000..ef46d1ac2c --- /dev/null +++ b/test/fiber/test_io.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true +require 'test/unit' +require_relative 'scheduler' + +class TestSchedulerIO < Test::Unit::TestCase + MESSAGE = "Hello World" + + def test_read + skip unless defined?(UNIXSocket) + + i, o = UNIXSocket.pair + skip unless i.nonblock? && o.nonblock? + + message = nil + + thread = Thread.new do + scheduler = Scheduler.new + Thread.current.scheduler = scheduler + + Fiber do + message = i.read(20) + i.close + end + + Fiber do + o.write("Hello World") + o.close + end + end + + thread.join + + assert_equal MESSAGE, message + end +end |