kgio.git  about / heads / tags
kinder, gentler I/O for Ruby
blob 8650f5efea3379c6b73b47a5ff9dd3e7c917592e 532 bytes (raw)
$ git show 2.4-stable:test/test_kgio_addr.rb	# shows this blob on the CLI

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
 
# -*- encoding: binary -*-
require 'test/unit'
$-w = true
require 'kgio'

class TestKgioAddr < Test::Unit::TestCase
  def test_tcp
    addr = ENV["TEST_HOST"] || '127.0.0.1'
    tcp = TCPServer.new(addr, 0)
    port = tcp.addr[1]
    client = Kgio::TCPSocket.new(addr, port)
    accepted = tcp.accept
    assert ! accepted.instance_eval { defined?(@kgio_addr) }
    accepted.extend Kgio::SocketMethods
    s = accepted.kgio_addr!
    assert_equal addr, s
    assert_equal addr, accepted.instance_variable_get(:@kgio_addr)
  end
end

git clone git://yhbt.net/kgio.git
git clone https://yhbt.net/kgio.git