diff options
Diffstat (limited to 'test/fiber/test_io.rb')
-rw-r--r-- | test/fiber/test_io.rb | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/test/fiber/test_io.rb b/test/fiber/test_io.rb index de88745e57..0e3e086d5a 100644 --- a/test/fiber/test_io.rb +++ b/test/fiber/test_io.rb @@ -170,6 +170,34 @@ class TestFiberIO < Test::Unit::TestCase assert_predicate(o, :closed?) end + def test_puts_empty + omit "UNIXSocket is not defined!" unless defined?(UNIXSocket) + + i, o = UNIXSocket.pair + i.nonblock = false + o.nonblock = false + + thread = Thread.new do + # This scheduler provides non-blocking `io_read`/`io_write`: + scheduler = IOBufferScheduler.new + Fiber.set_scheduler scheduler + + Fiber.schedule do + # This was causing a segfault on older Ruby. + o.puts "" + o.puts nil + o.close + end + end + + thread.join + + message = i.read + i.close + + assert_equal $/*2, message + end + def test_io_select omit "UNIXSocket is not defined!" unless defined?(UNIXSocket) @@ -191,4 +219,19 @@ class TestFiberIO < Test::Unit::TestCase assert_equal [[r], [w], []], result end end + + def test_backquote + result = nil + + thread = Thread.new do + scheduler = Scheduler.new + Fiber.set_scheduler scheduler + Fiber.schedule do + result = `#{EnvUtil.rubybin} -e "sleep 0.1;puts %[ok]"` + end + end + thread.join + + assert_equal "ok\n", result + end end |