* io.c (rb_open_file): encoding in mode string was ignored if perm is
[ruby-svn.git] / test / socket / test_udp.rb
blobd515ad4dbb5cb48a08386653ace0ff6231f5b14e
1 begin
2   require "socket"
3   require "test/unit"
4 rescue LoadError
5 end
8 class TestUDPSocket < Test::Unit::TestCase
9   def test_connect
10     s = UDPSocket.new
11     host = Object.new
12     class << host; self end.send(:define_method, :to_str) {
13       s.close
14       "127.0.0.1"
15     }
16     assert_raise(IOError, "[ruby-dev:25045]") {
17       s.connect(host, 1)
18     }
19   end
21   def test_bind
22     s = UDPSocket.new
23     host = Object.new
24     class << host; self end.send(:define_method, :to_str) {
25       s.close
26       "127.0.0.1"
27     }
28     assert_raise(IOError, "[ruby-dev:25057]") {
29       s.bind(host, 2000)
30     }
31   end
32 end if defined?(UDPSocket)