diff options
author | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-09-25 10:41:16 +0000 |
---|---|---|
committer | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-09-25 10:41:16 +0000 |
commit | e87fb88be844f0fae736768846954b6f6f7dc7c3 (patch) | |
tree | cbe2ab069e40b5b7f3217ce95b793426b303a305 /spec/ruby/library | |
parent | e59bf54b3a88d0465cca021afae7dc05b6db57a7 (diff) |
Update to ruby/spec@241f9e7
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64831 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/ruby/library')
38 files changed, 184 insertions, 115 deletions
diff --git a/spec/ruby/library/conditionvariable/wait_spec.rb b/spec/ruby/library/conditionvariable/wait_spec.rb index d4950a7b27..8bdb7829d3 100644 --- a/spec/ruby/library/conditionvariable/wait_spec.rb +++ b/spec/ruby/library/conditionvariable/wait_spec.rb @@ -52,39 +52,41 @@ describe "ConditionVariable#wait" do owned.should == true end - it "reacquires the lock even if the thread is killed after being signaled" do - m = Mutex.new - cv = ConditionVariable.new - in_synchronize = false - owned = nil - - th = Thread.new do - m.synchronize do - in_synchronize = true - begin - cv.wait(m) - ensure - owned = m.owned? - $stderr.puts "\nThe Thread doesn't own the Mutex!" unless owned + ruby_bug '#14999', ''...'2.5' do + it "reacquires the lock even if the thread is killed after being signaled" do + m = Mutex.new + cv = ConditionVariable.new + in_synchronize = false + owned = nil + + th = Thread.new do + m.synchronize do + in_synchronize = true + begin + cv.wait(m) + ensure + owned = m.owned? + $stderr.puts "\nThe Thread doesn't own the Mutex!" unless owned + end end end - end - - # wait for m to acquire the mutex - Thread.pass until in_synchronize - # wait until th is sleeping (ie waiting) - Thread.pass while th.status and th.status != "sleep" - m.synchronize { - cv.signal - # Wait that the thread is blocked on acquiring the Mutex - sleep 0.001 - # Kill the thread, yet the thread should first acquire the Mutex before going on - th.kill - } + # wait for m to acquire the mutex + Thread.pass until in_synchronize + # wait until th is sleeping (ie waiting) + Thread.pass while th.status and th.status != "sleep" + + m.synchronize { + cv.signal + # Wait that the thread is blocked on acquiring the Mutex + sleep 0.001 + # Kill the thread, yet the thread should first acquire the Mutex before going on + th.kill + } - th.join - owned.should == true + th.join + owned.should == true + end end it "supports multiple Threads waiting on the same ConditionVariable and Mutex" do diff --git a/spec/ruby/library/matrix/divide_spec.rb b/spec/ruby/library/matrix/divide_spec.rb index d656985f38..205bc5d892 100644 --- a/spec/ruby/library/matrix/divide_spec.rb +++ b/spec/ruby/library/matrix/divide_spec.rb @@ -14,13 +14,12 @@ describe "Matrix#/" do (@a / @b).should be_close_to_matrix([[2.5, -1.5], [1.5, -0.5]]) end - conflicts_with :Prime do + # Guard against the Mathn library + guard -> { !defined?(Math.rsqrt) } do it "returns the result of dividing self by a Fixnum" do (@a / 2).should == Matrix[ [0, 1], [1, 2] ] end - end - conflicts_with :Prime do it "returns the result of dividing self by a Bignum" do (@a / bignum_value).should == Matrix[ [0, 0], [0, 0] ] end diff --git a/spec/ruby/library/matrix/real_spec.rb b/spec/ruby/library/matrix/real_spec.rb index e3648e4769..38033c63c8 100644 --- a/spec/ruby/library/matrix/real_spec.rb +++ b/spec/ruby/library/matrix/real_spec.rb @@ -16,7 +16,8 @@ describe "Matrix#real?" do Matrix[ [Complex(1,1), 2], [3, 4] ].real?.should be_false end - conflicts_with :CMath do + # Guard against the Mathn library + guard -> { !defined?(Math.rsqrt) } do it "returns false if one element is a Complex whose imaginary part is 0" do Matrix[ [Complex(1,0), 2], [3, 4] ].real?.should be_false end diff --git a/spec/ruby/library/monitor/mon_initialize_spec.rb b/spec/ruby/library/monitor/mon_initialize_spec.rb new file mode 100644 index 0000000000..e0fe6c2d97 --- /dev/null +++ b/spec/ruby/library/monitor/mon_initialize_spec.rb @@ -0,0 +1,31 @@ +require_relative '../../spec_helper' +require 'monitor' + +describe "MonitorMixin#mon_initialize" do + it "can be called in initialize_copy to get a new Mutex and used with synchronize" do + cls = Class.new do + include MonitorMixin + + def initialize(*array) + mon_initialize + @array = array + end + + def to_a + synchronize { @array.dup } + end + + def initialize_copy(other) + mon_initialize + + synchronize do + @array = other.to_a + end + end + end + + instance = cls.new(1, 2, 3) + copy = instance.dup + copy.should_not equal(instance) + end +end diff --git a/spec/ruby/library/rbconfig/sizeof/sizeof_spec.rb b/spec/ruby/library/rbconfig/sizeof/sizeof_spec.rb new file mode 100644 index 0000000000..f2582dc4fd --- /dev/null +++ b/spec/ruby/library/rbconfig/sizeof/sizeof_spec.rb @@ -0,0 +1,30 @@ +require_relative '../../../spec_helper' +require 'rbconfig/sizeof' + +describe "RbConfig::SIZEOF" do + it "is a Hash" do + RbConfig::SIZEOF.should be_kind_of(Hash) + end + + it "has string keys and integer values" do + RbConfig::SIZEOF.each do |key, value| + key.should be_kind_of String + value.should be_kind_of Integer + end + end + + it "contains the sizeof(void*)" do + (RbConfig::SIZEOF["void*"] * 8).should == PlatformGuard::POINTER_SIZE + end + + it "contains the sizeof(float) and sizeof(double)" do + RbConfig::SIZEOF["float"].should == 4 + RbConfig::SIZEOF["double"].should == 8 + end + + it "contains the size of short, int and long" do + RbConfig::SIZEOF["short"].should > 0 + RbConfig::SIZEOF["int"].should > 0 + RbConfig::SIZEOF["long"].should > 0 + end +end diff --git a/spec/ruby/library/socket/addrinfo/getnameinfo_spec.rb b/spec/ruby/library/socket/addrinfo/getnameinfo_spec.rb index 3c1a37d9fb..c5284f1c0f 100644 --- a/spec/ruby/library/socket/addrinfo/getnameinfo_spec.rb +++ b/spec/ruby/library/socket/addrinfo/getnameinfo_spec.rb @@ -13,7 +13,7 @@ describe 'Addrinfo#getnameinfo' do service.should == 'ftp' end - it 'accepts flags as a Fixnum as the first argument' do + it 'accepts flags as an Integer as the first argument' do host, service = @addr.getnameinfo(Socket::NI_NUMERICSERV) service.should == '21' end diff --git a/spec/ruby/library/socket/ancillarydata/family_spec.rb b/spec/ruby/library/socket/ancillarydata/family_spec.rb index b742e0c6db..975f0d2538 100644 --- a/spec/ruby/library/socket/ancillarydata/family_spec.rb +++ b/spec/ruby/library/socket/ancillarydata/family_spec.rb @@ -2,7 +2,7 @@ require_relative '../spec_helper' with_feature :ancillary_data do describe 'Socket::AncillaryData#family' do - it 'returns the family as a Fixnum' do + it 'returns the family as an Integer' do Socket::AncillaryData.new(:INET, :SOCKET, :RIGHTS, '').family.should == Socket::AF_INET end end diff --git a/spec/ruby/library/socket/ancillarydata/initialize_spec.rb b/spec/ruby/library/socket/ancillarydata/initialize_spec.rb index c700404799..d4788d0f68 100644 --- a/spec/ruby/library/socket/ancillarydata/initialize_spec.rb +++ b/spec/ruby/library/socket/ancillarydata/initialize_spec.rb @@ -2,7 +2,7 @@ require_relative '../spec_helper' with_feature :ancillary_data do describe 'Socket::AncillaryData#initialize' do - describe 'using Fixnums for the family, level, and type' do + describe 'using Integers for the family, level, and type' do before do @data = Socket::AncillaryData .new(Socket::AF_INET, Socket::IPPROTO_IP, Socket::IP_RECVTTL, 'ugh') diff --git a/spec/ruby/library/socket/ancillarydata/int_spec.rb b/spec/ruby/library/socket/ancillarydata/int_spec.rb index 75608a28b8..0d7c5e3652 100644 --- a/spec/ruby/library/socket/ancillarydata/int_spec.rb +++ b/spec/ruby/library/socket/ancillarydata/int_spec.rb @@ -28,13 +28,13 @@ with_feature :ancillary_data do end describe 'Socket::AncillaryData#int' do - it 'returns the data as a Fixnum' do + it 'returns the data as an Integer' do data = Socket::AncillaryData.int(:UNIX, :SOCKET, :RIGHTS, 4) data.int.should == 4 end - it 'raises when the data is not a Fixnum' do + it 'raises when the data is not an Integer' do data = Socket::AncillaryData.new(:UNIX, :SOCKET, :RIGHTS, 'ugh') lambda { data.int }.should raise_error(TypeError) diff --git a/spec/ruby/library/socket/ancillarydata/ip_pktinfo_spec.rb b/spec/ruby/library/socket/ancillarydata/ip_pktinfo_spec.rb index 1bc92e3373..809d087161 100644 --- a/spec/ruby/library/socket/ancillarydata/ip_pktinfo_spec.rb +++ b/spec/ruby/library/socket/ancillarydata/ip_pktinfo_spec.rb @@ -71,7 +71,7 @@ with_feature :ancillary_data, :pktinfo do end it 'stores the ifindex at index 1' do - @info[1].should be_an_instance_of(Fixnum) + @info[1].should be_kind_of(Integer) end it 'stores an Addrinfo at index 2' do @@ -94,7 +94,7 @@ with_feature :ancillary_data, :pktinfo do end describe 'the ifindex' do - it 'is a Fixnum' do + it 'is an Integer' do @data.ip_pktinfo[1].should == 4 end end diff --git a/spec/ruby/library/socket/ancillarydata/ipv6_pktinfo_spec.rb b/spec/ruby/library/socket/ancillarydata/ipv6_pktinfo_spec.rb index 6315aba89c..dfaa5bf0f5 100644 --- a/spec/ruby/library/socket/ancillarydata/ipv6_pktinfo_spec.rb +++ b/spec/ruby/library/socket/ancillarydata/ipv6_pktinfo_spec.rb @@ -44,7 +44,7 @@ with_feature :ancillary_data, :ipv6_pktinfo do end it 'stores the ifindex at index 1' do - @info[1].should be_an_instance_of(Fixnum) + @info[1].should be_kind_of(Integer) end end @@ -63,7 +63,7 @@ with_feature :ancillary_data, :ipv6_pktinfo do end describe 'the ifindex' do - it 'is a Fixnum' do + it 'is an Integer' do @data.ipv6_pktinfo[1].should == 4 end end diff --git a/spec/ruby/library/socket/ancillarydata/level_spec.rb b/spec/ruby/library/socket/ancillarydata/level_spec.rb index 40b070a6d8..a2ff216f9d 100644 --- a/spec/ruby/library/socket/ancillarydata/level_spec.rb +++ b/spec/ruby/library/socket/ancillarydata/level_spec.rb @@ -2,7 +2,7 @@ require_relative '../spec_helper' with_feature :ancillary_data do describe 'Socket::AncillaryData#level' do - it 'returns the level as a Fixnum' do + it 'returns the level as an Integer' do Socket::AncillaryData.new(:INET, :SOCKET, :RIGHTS, '').level.should == Socket::SOL_SOCKET end end diff --git a/spec/ruby/library/socket/ancillarydata/type_spec.rb b/spec/ruby/library/socket/ancillarydata/type_spec.rb index 1a4b04ed57..972beeeca0 100644 --- a/spec/ruby/library/socket/ancillarydata/type_spec.rb +++ b/spec/ruby/library/socket/ancillarydata/type_spec.rb @@ -2,7 +2,7 @@ require_relative '../spec_helper' with_feature :ancillary_data do describe 'Socket::AncillaryData#type' do - it 'returns the type as a Fixnum' do + it 'returns the type as an Integer' do Socket::AncillaryData.new(:INET, :SOCKET, :RIGHTS, '').type.should == Socket::SCM_RIGHTS end end diff --git a/spec/ruby/library/socket/basicsocket/getsockopt_spec.rb b/spec/ruby/library/socket/basicsocket/getsockopt_spec.rb index 926d7505e8..aad21ca535 100644 --- a/spec/ruby/library/socket/basicsocket/getsockopt_spec.rb +++ b/spec/ruby/library/socket/basicsocket/getsockopt_spec.rb @@ -59,7 +59,7 @@ describe "BasicSocket#getsockopt" do it 'returns a Socket::Option for a numeric option' do opt = @sock.getsockopt(Socket::IPPROTO_IP, Socket::IP_TTL) - opt.int.should be_an_instance_of(Fixnum) + opt.int.should be_kind_of(Integer) end it 'returns a Socket::Option for a struct option' do @@ -171,7 +171,7 @@ describe "BasicSocket#getsockopt" do opt = @sock.getsockopt(Socket::IPPROTO_IP, Socket::IP_TTL).to_s array = opt.unpack('i') - array[0].should be_an_instance_of(Fixnum) + array[0].should be_kind_of(Integer) array[0].should > 0 end diff --git a/spec/ruby/library/socket/basicsocket/recvmsg_nonblock_spec.rb b/spec/ruby/library/socket/basicsocket/recvmsg_nonblock_spec.rb index 70708e0cbc..8f6b75029c 100644 --- a/spec/ruby/library/socket/basicsocket/recvmsg_nonblock_spec.rb +++ b/spec/ruby/library/socket/basicsocket/recvmsg_nonblock_spec.rb @@ -75,7 +75,7 @@ describe 'BasicSocket#recvmsg_nonblock' do platform_is_not :windows do it 'stores the flags at index 2' do - @array[2].should be_an_instance_of(Fixnum) + @array[2].should be_kind_of(Integer) end end @@ -169,7 +169,7 @@ describe 'BasicSocket#recvmsg_nonblock' do end it 'stores the flags at index 2' do - @array[2].should be_an_instance_of(Fixnum) + @array[2].should be_kind_of(Integer) end describe 'the returned Addrinfo' do diff --git a/spec/ruby/library/socket/basicsocket/recvmsg_spec.rb b/spec/ruby/library/socket/basicsocket/recvmsg_spec.rb index d7de83d72b..58eb8d0360 100644 --- a/spec/ruby/library/socket/basicsocket/recvmsg_spec.rb +++ b/spec/ruby/library/socket/basicsocket/recvmsg_spec.rb @@ -71,7 +71,7 @@ describe 'BasicSocket#recvmsg' do platform_is_not :windows do it 'stores the flags at index 2' do - @array[2].should be_an_instance_of(Fixnum) + @array[2].should be_kind_of(Integer) end end @@ -161,7 +161,7 @@ describe 'BasicSocket#recvmsg' do end it 'stores the flags at index 2' do - @array[2].should be_an_instance_of(Fixnum) + @array[2].should be_kind_of(Integer) end describe 'the returned Addrinfo' do diff --git a/spec/ruby/library/socket/basicsocket/shutdown_spec.rb b/spec/ruby/library/socket/basicsocket/shutdown_spec.rb index 40e2d77570..87a32ae1dc 100644 --- a/spec/ruby/library/socket/basicsocket/shutdown_spec.rb +++ b/spec/ruby/library/socket/basicsocket/shutdown_spec.rb @@ -19,7 +19,7 @@ platform_is_not :windows do # hangs @server.close end - describe 'using a Fixnum' do + describe 'using an Integer' do it 'shuts down a socket for reading' do @client.shutdown(Socket::SHUT_RD) diff --git a/spec/ruby/library/socket/option/initialize_spec.rb b/spec/ruby/library/socket/option/initialize_spec.rb index 986cfa8ad4..0d4621b71e 100644 --- a/spec/ruby/library/socket/option/initialize_spec.rb +++ b/spec/ruby/library/socket/option/initialize_spec.rb @@ -5,7 +5,7 @@ describe 'Socket::Option#initialize' do @bool = [0].pack('i') end - describe 'using Fixnums' do + describe 'using Integers' do it 'returns a Socket::Option' do opt = Socket::Option .new(Socket::AF_INET, Socket::SOL_SOCKET, Socket::SO_KEEPALIVE, @bool) diff --git a/spec/ruby/library/socket/shared/socketpair.rb b/spec/ruby/library/socket/shared/socketpair.rb index 1e08deccc2..08db2e59b8 100644 --- a/spec/ruby/library/socket/shared/socketpair.rb +++ b/spec/ruby/library/socket/shared/socketpair.rb @@ -20,7 +20,7 @@ describe :socket_socketpair, shared: true do end end - describe 'using a Fixnum as the 1st and 2nd argument' do + describe 'using an Integer as the 1st and 2nd argument' do it 'returns two Socket objects' do s1, s2 = Socket.public_send(@method, Socket::AF_UNIX, Socket::SOCK_STREAM) @@ -116,7 +116,7 @@ describe :socket_socketpair, shared: true do end end - it 'accepts a custom protocol as a Fixnum as the 3rd argument' do + it 'accepts a custom protocol as an Integer as the 3rd argument' do s1, s2 = Socket.public_send(@method, :UNIX, :STREAM, Socket::IPPROTO_IP) s1.should be_an_instance_of(Socket) s2.should be_an_instance_of(Socket) diff --git a/spec/ruby/library/socket/socket/connect_nonblock_spec.rb b/spec/ruby/library/socket/socket/connect_nonblock_spec.rb index 037dc39131..0012b5ada7 100644 --- a/spec/ruby/library/socket/socket/connect_nonblock_spec.rb +++ b/spec/ruby/library/socket/socket/connect_nonblock_spec.rb @@ -94,7 +94,7 @@ describe 'Socket#connect_nonblock' do @client.connect_nonblock(@server.connect_address).should == 0 end - it 'raises TypeError when passed a Fixnum' do + it 'raises TypeError when passed an Integer' do lambda { @client.connect_nonblock(666) }.should raise_error(TypeError) end end diff --git a/spec/ruby/library/socket/socket/getaddrinfo_spec.rb b/spec/ruby/library/socket/socket/getaddrinfo_spec.rb index a4b6ada2e5..e0eff3cef4 100644 --- a/spec/ruby/library/socket/socket/getaddrinfo_spec.rb +++ b/spec/ruby/library/socket/socket/getaddrinfo_spec.rb @@ -115,7 +115,7 @@ describe 'Socket.getaddrinfo' do Socket.getaddrinfo(nil, 'ftp').should be_an_instance_of(Array) end - it 'accepts a Fixnum as the address family' do + it 'accepts an Integer as the address family' do array = Socket.getaddrinfo(nil, 'ftp', Socket::AF_INET)[0] array[0].should == 'AF_INET' @@ -123,11 +123,11 @@ describe 'Socket.getaddrinfo' do array[2].should == '127.0.0.1' array[3].should == '127.0.0.1' array[4].should == Socket::AF_INET - array[5].should be_an_instance_of(Fixnum) - array[6].should be_an_instance_of(Fixnum) + array[5].should be_kind_of(Integer) + array[6].should be_kind_of(Integer) end - it 'accepts a Fixnum as the address family using IPv6' do + it 'accepts an Integer as the address family using IPv6' do array = Socket.getaddrinfo(nil, 'ftp', Socket::AF_INET6)[0] array[0].should == 'AF_INET6' @@ -135,8 +135,8 @@ describe 'Socket.getaddrinfo' do array[2].should == '::1' array[3].should == '::1' array[4].should == Socket::AF_INET6 - array[5].should be_an_instance_of(Fixnum) - array[6].should be_an_instance_of(Fixnum) + array[5].should be_kind_of(Integer) + array[6].should be_kind_of(Integer) end it 'accepts a Symbol as the address family' do @@ -147,8 +147,8 @@ describe 'Socket.getaddrinfo' do array[2].should == '127.0.0.1' array[3].should == '127.0.0.1' array[4].should == Socket::AF_INET - array[5].should be_an_instance_of(Fixnum) - array[6].should be_an_instance_of(Fixnum) + array[5].should be_kind_of(Integer) + array[6].should be_kind_of(Integer) end it 'accepts a Symbol as the address family using IPv6' do @@ -159,8 +159,8 @@ describe 'Socket.getaddrinfo' do array[2].should == '::1' array[3].should == '::1' array[4].should == Socket::AF_INET6 - array[5].should be_an_instance_of(Fixnum) - array[6].should be_an_instance_of(Fixnum) + array[5].should be_kind_of(Integer) + array[6].should be_kind_of(Integer) end it 'accepts a String as the address family' do @@ -171,8 +171,8 @@ describe 'Socket.getaddrinfo' do array[2].should == '127.0.0.1' array[3].should == '127.0.0.1' array[4].should == Socket::AF_INET - array[5].should be_an_instance_of(Fixnum) - array[6].should be_an_instance_of(Fixnum) + array[5].should be_kind_of(Integer) + array[6].should be_kind_of(Integer) end it 'accepts a String as the address family using IPv6' do @@ -183,8 +183,8 @@ describe 'Socket.getaddrinfo' do array[2].should == '::1' array[3].should == '::1' array[4].should == Socket::AF_INET6 - array[5].should be_an_instance_of(Fixnum) - array[6].should be_an_instance_of(Fixnum) + array[5].should be_kind_of(Integer) + array[6].should be_kind_of(Integer) end it 'accepts an object responding to #to_str as the host' do @@ -199,8 +199,8 @@ describe 'Socket.getaddrinfo' do array[2].should == '127.0.0.1' array[3].should == '127.0.0.1' array[4].should == Socket::AF_INET - array[5].should be_an_instance_of(Fixnum) - array[6].should be_an_instance_of(Fixnum) + array[5].should be_kind_of(Integer) + array[6].should be_kind_of(Integer) end it 'accepts an object responding to #to_str as the address family' do @@ -215,11 +215,11 @@ describe 'Socket.getaddrinfo' do array[2].should == '127.0.0.1' array[3].should == '127.0.0.1' array[4].should == Socket::AF_INET - array[5].should be_an_instance_of(Fixnum) - array[6].should be_an_instance_of(Fixnum) + array[5].should be_kind_of(Integer) + array[6].should be_kind_of(Integer) end - it 'accepts a Fixnum as the socket type' do + it 'accepts an Integer as the socket type' do *array, proto = Socket.getaddrinfo(nil, 'ftp', :INET, Socket::SOCK_STREAM)[0] array.should == [ 'AF_INET', @@ -276,7 +276,7 @@ describe 'Socket.getaddrinfo' do end platform_is_not :windows do - it 'accepts a Fixnum as the protocol family' do + it 'accepts an Integer as the protocol family' do *array, proto = Socket.getaddrinfo(nil, 'discard', :INET, :DGRAM, Socket::IPPROTO_UDP)[0] array.should == [ 'AF_INET', @@ -290,7 +290,7 @@ describe 'Socket.getaddrinfo' do end end - it 'accepts a Fixnum as the flags' do + it 'accepts an Integer as the flags' do *array, proto = Socket.getaddrinfo(nil, 'ftp', :INET, :STREAM, Socket::IPPROTO_TCP, Socket::AI_PASSIVE)[0] array.should == [ diff --git a/spec/ruby/library/socket/socket/gethostbyaddr_spec.rb b/spec/ruby/library/socket/socket/gethostbyaddr_spec.rb index 08cadcf93b..639a318132 100644 --- a/spec/ruby/library/socket/socket/gethostbyaddr_spec.rb +++ b/spec/ruby/library/socket/socket/gethostbyaddr_spec.rb @@ -48,7 +48,7 @@ describe 'Socket.gethostbyaddr' do end describe 'with an explicit address family' do - it 'returns an Array when using a Fixnum as the address family' do + it 'returns an Array when using an Integer as the address family' do Socket.gethostbyaddr(@addr, Socket::AF_INET).should be_an_instance_of(Array) end @@ -105,7 +105,7 @@ describe 'Socket.gethostbyaddr' do end describe 'with an explicit address family' do - it 'returns an Array when using a Fixnum as the address family' do + it 'returns an Array when using an Integer as the address family' do Socket.gethostbyaddr(@addr, Socket::AF_INET6).should be_an_instance_of(Array) end diff --git a/spec/ruby/library/socket/socket/getifaddrs_spec.rb b/spec/ruby/library/socket/socket/getifaddrs_spec.rb index 588a355700..ad23499ef9 100644 --- a/spec/ruby/library/socket/socket/getifaddrs_spec.rb +++ b/spec/ruby/library/socket/socket/getifaddrs_spec.rb @@ -25,7 +25,7 @@ describe 'Socket.getifaddrs' do describe 'each returned Socket::Ifaddr' do it 'has an interface index' do @ifaddrs.each do |ifaddr| - ifaddr.ifindex.should be_an_instance_of(Fixnum) + ifaddr.ifindex.should be_kind_of(Integer) end end @@ -37,7 +37,7 @@ describe 'Socket.getifaddrs' do it 'has a set of flags' do @ifaddrs.each do |ifaddr| - ifaddr.flags.should be_an_instance_of(Fixnum) + ifaddr.flags.should be_kind_of(Integer) end end end @@ -55,7 +55,7 @@ describe 'Socket.getifaddrs' do it 'has an address family' do @addrs.each do |addr| - addr.afamily.should be_an_instance_of(Fixnum) + addr.afamily.should be_kind_of(Integer) addr.afamily.should_not == Socket::AF_UNSPEC end end @@ -75,7 +75,7 @@ describe 'Socket.getifaddrs' do it 'has an address family' do @addrs.each do |addr| - addr.afamily.should be_an_instance_of(Fixnum) + addr.afamily.should be_kind_of(Integer) addr.afamily.should_not == Socket::AF_UNSPEC end end @@ -94,7 +94,7 @@ describe 'Socket.getifaddrs' do it 'has an address family' do @addrs.each do |addr| - addr.afamily.should be_an_instance_of(Fixnum) + addr.afamily.should be_kind_of(Integer) addr.afamily.should_not == Socket::AF_UNSPEC end end diff --git a/spec/ruby/library/socket/socket/initialize_spec.rb b/spec/ruby/library/socket/socket/initialize_spec.rb index 375eabfbcb..2343c6e289 100644 --- a/spec/ruby/library/socket/socket/initialize_spec.rb +++ b/spec/ruby/library/socket/socket/initialize_spec.rb @@ -9,7 +9,7 @@ describe 'Socket#initialize' do @socket.close if @socket end - describe 'using a Fixnum as the 1st and 2nd arguments' do + describe 'using an Integer as the 1st and 2nd arguments' do it 'returns a Socket' do @socket = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM) @@ -58,7 +58,7 @@ describe 'Socket#initialize' do end describe 'using a custom protocol' do - it 'returns a Socket when using a Fixnum' do + it 'returns a Socket when using an Integer' do @socket = Socket.new(:INET, :STREAM, Socket::IPPROTO_TCP) @socket.should be_an_instance_of(Socket) diff --git a/spec/ruby/library/socket/socket/listen_spec.rb b/spec/ruby/library/socket/socket/listen_spec.rb index 326307f942..d0f9c70c4e 100644 --- a/spec/ruby/library/socket/socket/listen_spec.rb +++ b/spec/ruby/library/socket/socket/listen_spec.rb @@ -56,7 +56,7 @@ describe 'Socket#listen' do @server.listen(1).should == 0 end - it "raises when the given argument can't be coerced to a Fixnum" do + it "raises when the given argument can't be coerced to an Integer" do lambda { @server.listen('cats') }.should raise_error(TypeError) end end diff --git a/spec/ruby/library/socket/socket/sysaccept_spec.rb b/spec/ruby/library/socket/socket/sysaccept_spec.rb index 3832041818..f039096707 100644 --- a/spec/ruby/library/socket/socket/sysaccept_spec.rb +++ b/spec/ruby/library/socket/socket/sysaccept_spec.rb @@ -75,10 +75,10 @@ describe 'Socket#sysaccept' do @client.close end - it 'returns an Array containing a Fixnum and an Addrinfo' do + it 'returns an Array containing an Integer and an Addrinfo' do @fd, addrinfo = @server.sysaccept - @fd.should be_an_instance_of(Fixnum) + @fd.should be_kind_of(Integer) addrinfo.should be_an_instance_of(Addrinfo) end diff --git a/spec/ruby/library/socket/tcpserver/initialize_spec.rb b/spec/ruby/library/socket/tcpserver/initialize_spec.rb index 9a55cf17e2..412bdbfb9d 100644 --- a/spec/ruby/library/socket/tcpserver/initialize_spec.rb +++ b/spec/ruby/library/socket/tcpserver/initialize_spec.rb @@ -2,7 +2,7 @@ require_relative '../spec_helper' require_relative '../fixtures/classes' describe 'TCPServer#initialize' do - describe 'with a single Fixnum argument' do + describe 'with a single Integer argument' do before do @server = TCPServer.new(0) end @@ -12,7 +12,7 @@ describe 'TCPServer#initialize' do end it 'sets the port to the given argument' do - @server.local_address.ip_port.should be_an_instance_of(Fixnum) + @server.local_address.ip_port.should be_kind_of(Integer) @server.local_address.ip_port.should > 0 end @@ -38,7 +38,7 @@ describe 'TCPServer#initialize' do end it 'sets the port to the given argument' do - @server.local_address.ip_port.should be_an_instance_of(Fixnum) + @server.local_address.ip_port.should be_kind_of(Integer) @server.local_address.ip_port.should > 0 end @@ -56,7 +56,7 @@ describe 'TCPServer#initialize' do end end - describe 'with a String and a Fixnum' do + describe 'with a String and an Integer' do SocketSpecs.each_ip_protocol do |family, ip_address| before do @server = TCPServer.new(ip_address, 0) @@ -67,7 +67,7 @@ describe 'TCPServer#initialize' do end it 'sets the port to the given port argument' do - @server.local_address.ip_port.should be_an_instance_of(Fixnum) + @server.local_address.ip_port.should be_kind_of(Integer) @server.local_address.ip_port.should > 0 end @@ -90,7 +90,7 @@ describe 'TCPServer#initialize' do end it 'sets the port to the given port argument' do - @server.local_address.ip_port.should be_an_instance_of(Fixnum) + @server.local_address.ip_port.should be_kind_of(Integer) @server.local_address.ip_port.should > 0 end diff --git a/spec/ruby/library/socket/tcpserver/listen_spec.rb b/spec/ruby/library/socket/tcpserver/listen_spec.rb index 1e17de06f1..e266decd61 100644 --- a/spec/ruby/library/socket/tcpserver/listen_spec.rb +++ b/spec/ruby/library/socket/tcpserver/listen_spec.rb @@ -15,7 +15,7 @@ describe 'TCPServer#listen' do @server.listen(1).should == 0 end - it "raises when the given argument can't be coerced to a Fixnum" do + it "raises when the given argument can't be coerced to an Integer" do lambda { @server.listen('cats') }.should raise_error(TypeError) end end diff --git a/spec/ruby/library/socket/tcpserver/new_spec.rb b/spec/ruby/library/socket/tcpserver/new_spec.rb index 94033411e3..4717b95a2c 100644 --- a/spec/ruby/library/socket/tcpserver/new_spec.rb +++ b/spec/ruby/library/socket/tcpserver/new_spec.rb @@ -10,7 +10,7 @@ describe "TCPServer.new" do @server = TCPServer.new('127.0.0.1', 0) addr = @server.addr addr[0].should == 'AF_INET' - addr[1].should be_kind_of(Fixnum) + addr[1].should be_kind_of(Integer) # on some platforms (Mac), MRI # returns comma at the end. addr[2].should =~ /^#{SocketSpecs.hostname}\b/ @@ -20,7 +20,7 @@ describe "TCPServer.new" do it "binds to localhost and a port with either IPv4 or IPv6" do @server = TCPServer.new(SocketSpecs.hostname, 0) addr = @server.addr - addr[1].should be_kind_of(Fixnum) + addr[1].should be_kind_of(Integer) if addr[0] == 'AF_INET' addr[2].should =~ /^#{SocketSpecs.hostname}\b/ addr[3].should == '127.0.0.1' @@ -34,7 +34,7 @@ describe "TCPServer.new" do @server = TCPServer.new('', 0) addr = @server.addr addr[0].should == 'AF_INET' - addr[1].should be_kind_of(Fixnum) + addr[1].should be_kind_of(Integer) addr[2].should == '0.0.0.0' addr[3].should == '0.0.0.0' end @@ -43,7 +43,7 @@ describe "TCPServer.new" do @server = TCPServer.new('', 0) addr = @server.addr addr[0].should == 'AF_INET' - addr[1].should be_kind_of(Fixnum) + addr[1].should be_kind_of(Integer) addr[2].should == '0.0.0.0' addr[3].should == '0.0.0.0' end @@ -56,7 +56,7 @@ describe "TCPServer.new" do @server = TCPServer.new(SocketSpecs.hostname, port) addr = @server.addr - addr[1].should be_kind_of(Fixnum) + addr[1].should be_kind_of(Integer) # TODO: This should also accept strings like 'https', but I don't know how to # pick such a service port that will be able to reliably bind... diff --git a/spec/ruby/library/socket/tcpserver/sysaccept_spec.rb b/spec/ruby/library/socket/tcpserver/sysaccept_spec.rb index 144b6806f1..5543b67755 100644 --- a/spec/ruby/library/socket/tcpserver/sysaccept_spec.rb +++ b/spec/ruby/library/socket/tcpserver/sysaccept_spec.rb @@ -21,7 +21,7 @@ describe "TCPServer#sysaccept" do fd = @server.sysaccept - fd.should be_an_instance_of(Fixnum) + fd.should be_kind_of(Integer) ensure sock.close if sock && !sock.closed? IO.for_fd(fd).close if fd @@ -55,10 +55,10 @@ describe 'TCPServer#sysaccept' do @client.close end - it 'returns a new file descriptor as a Fixnum' do + it 'returns a new file descriptor as an Integer' do @fd = @server.sysaccept - @fd.should be_an_instance_of(Fixnum) + @fd.should be_kind_of(Integer) @fd.should_not == @client.fileno end end diff --git a/spec/ruby/library/socket/tcpsocket/gethostbyname_spec.rb b/spec/ruby/library/socket/tcpsocket/gethostbyname_spec.rb index 230d14bfb0..703abff81c 100644 --- a/spec/ruby/library/socket/tcpsocket/gethostbyname_spec.rb +++ b/spec/ruby/library/socket/tcpsocket/gethostbyname_spec.rb @@ -70,7 +70,7 @@ describe 'TCPSocket#gethostbyname' do end it 'includes the address family as the 3rd value' do - @array[2].should be_an_instance_of(Fixnum) + @array[2].should be_kind_of(Integer) end it 'includes the IP addresses as all the remaining values' do diff --git a/spec/ruby/library/socket/tcpsocket/initialize_spec.rb b/spec/ruby/library/socket/tcpsocket/initialize_spec.rb index 184f9abb7d..a3593f0d5f 100644 --- a/spec/ruby/library/socket/tcpsocket/initialize_spec.rb +++ b/spec/ruby/library/socket/tcpsocket/initialize_spec.rb @@ -20,7 +20,7 @@ describe 'TCPSocket#initialize' do @server.close end - it 'returns a TCPSocket when using a Fixnum as the port' do + it 'returns a TCPSocket when using an Integer as the port' do @client = TCPSocket.new(ip_address, @port) @client.should be_an_instance_of(TCPSocket) end diff --git a/spec/ruby/library/socket/tcpsocket/shared/new.rb b/spec/ruby/library/socket/tcpsocket/shared/new.rb index 818bd69a91..d0358923c9 100644 --- a/spec/ruby/library/socket/tcpsocket/shared/new.rb +++ b/spec/ruby/library/socket/tcpsocket/shared/new.rb @@ -72,7 +72,7 @@ describe :tcpsocket_new, shared: true do @socket.addr[3].should == SocketSpecs.addr(:ipv6) end - @socket.addr[1].should be_kind_of(Fixnum) + @socket.addr[1].should be_kind_of(Integer) @socket.addr[2].should =~ /^#{@hostname}/ end end diff --git a/spec/ruby/library/socket/udpsocket/initialize_spec.rb b/spec/ruby/library/socket/udpsocket/initialize_spec.rb index 5df3bf9800..06f7b5ef1c 100644 --- a/spec/ruby/library/socket/udpsocket/initialize_spec.rb +++ b/spec/ruby/library/socket/udpsocket/initialize_spec.rb @@ -10,7 +10,7 @@ describe 'UDPSocket#initialize' do @socket.should be_an_instance_of(UDPSocket) end - it 'initializes a new UDPSocket using a Fixnum' do + it 'initializes a new UDPSocket using an Integer' do @socket = UDPSocket.new(Socket::AF_INET) @socket.should be_an_instance_of(UDPSocket) end diff --git a/spec/ruby/library/socket/udpsocket/new_spec.rb b/spec/ruby/library/socket/udpsocket/new_spec.rb index 30e7103d16..157ff138be 100644 --- a/spec/ruby/library/socket/udpsocket/new_spec.rb +++ b/spec/ruby/library/socket/udpsocket/new_spec.rb @@ -11,7 +11,7 @@ describe 'UDPSocket.new' do @socket.should be_an_instance_of(UDPSocket) end - it 'using Fixnum argument' do + it 'using Integer argument' do @socket = UDPSocket.new(Socket::AF_INET) @socket.should be_an_instance_of(UDPSocket) end diff --git a/spec/ruby/library/socket/udpsocket/send_spec.rb b/spec/ruby/library/socket/udpsocket/send_spec.rb index b84e84b056..431129723e 100644 --- a/spec/ruby/library/socket/udpsocket/send_spec.rb +++ b/spec/ruby/library/socket/udpsocket/send_spec.rb @@ -34,7 +34,7 @@ describe "UDPSocket#send" do @msg[0].should == "ad hoc" @msg[1][0].should == "AF_INET" - @msg[1][1].should be_kind_of(Fixnum) + @msg[1][1].should be_kind_of(Integer) @msg[1][3].should == "127.0.0.1" end @@ -46,7 +46,7 @@ describe "UDPSocket#send" do @msg[0].should == "ad hoc" @msg[1][0].should == "AF_INET" - @msg[1][1].should be_kind_of(Fixnum) + @msg[1][1].should be_kind_of(Integer) @msg[1][3].should == "127.0.0.1" end @@ -59,7 +59,7 @@ describe "UDPSocket#send" do @msg[0].should == "connection-based" @msg[1][0].should == "AF_INET" - @msg[1][1].should be_kind_of(Fixnum) + @msg[1][1].should be_kind_of(Integer) @msg[1][3].should == "127.0.0.1" end diff --git a/spec/ruby/library/socket/unixserver/sysaccept_spec.rb b/spec/ruby/library/socket/unixserver/sysaccept_spec.rb index 864913af82..65a35c91a9 100644 --- a/spec/ruby/library/socket/unixserver/sysaccept_spec.rb +++ b/spec/ruby/library/socket/unixserver/sysaccept_spec.rb @@ -31,9 +31,9 @@ with_feature :unix_socket do end describe 'without any data' do - it 'returns a Fixnum' do + it 'returns an Integer' do @fd = @server.sysaccept - @fd.should be_an_instance_of(Fixnum) + @fd.should be_kind_of(Integer) end end @@ -42,9 +42,9 @@ with_feature :unix_socket do @client.write('hello') end - it 'returns a Fixnum' do + it 'returns an Integer' do @fd = @server.sysaccept - @fd.should be_an_instance_of(Fixnum) + @fd.should be_kind_of(Integer) end end end diff --git a/spec/ruby/library/stringio/external_encoding_spec.rb b/spec/ruby/library/stringio/external_encoding_spec.rb index 9c3d4041e5..6c5edb1713 100644 --- a/spec/ruby/library/stringio/external_encoding_spec.rb +++ b/spec/ruby/library/stringio/external_encoding_spec.rb @@ -8,6 +8,12 @@ describe "StringIO#external_encoding" do io.external_encoding.should == Encoding::EUC_JP end + it "changes to match string if string's encoding is changed" do + io = StringIO.new + io.string.force_encoding(Encoding::EUC_JP) + io.external_encoding.should == Encoding::EUC_JP + end + it "does not set the encoding of its buffer string if the string is frozen" do str = "foo".freeze enc = str.encoding |