drop remaining 1.8 and fragile autopush code paths
[kgio.git] / test / test_cross_thread_close.rb
blob05c32de1c2ab23853132046396db71239cd73601
1 require 'test/unit'
2 $-w = true
3 require 'kgio'
5 class TestCrossThreadClose < Test::Unit::TestCase
7   def test_cross_thread_close
8     host = ENV["TEST_HOST"] || '127.0.0.1'
9     srv = Kgio::TCPServer.new(host, 0)
10     thr = Thread.new do
11       begin
12         srv.kgio_accept
13       rescue => e
14         e
15       end
16     end
17     sleep(0.1) until thr.stop?
18     srv.close
19     unless defined?(RUBY_ENGINE) && RUBY_ENGINE == "ruby" &&
20            RUBY_VERSION == "1.9.3"
21       thr.run rescue nil
22     end
23     thr.join
24     assert_kind_of IOError, thr.value
25   end
26 end if defined?(RUBY_ENGINE) && RUBY_ENGINE == "ruby"