ruby-changes:51965
From: eregon <ko1@a...>
Date: Sat, 4 Aug 2018 01:19:52 +0900 (JST)
Subject: [ruby-changes:51965] eregon:r64180 (trunk): Update to ruby/spec@9be7c7e
eregon 2018-08-04 01:19:40 +0900 (Sat, 04 Aug 2018) New Revision: 64180 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=64180 Log: Update to ruby/spec@9be7c7e Added directories: trunk/spec/ruby/core/signal/fixtures/ trunk/spec/ruby/library/socket/ancillarydata/ Added files: trunk/spec/ruby/core/module/fixtures/autoload_callback.rb trunk/spec/ruby/core/module/fixtures/autoload_during_autoload.rb trunk/spec/ruby/core/module/fixtures/autoload_during_require.rb trunk/spec/ruby/core/module/fixtures/autoload_exception.rb trunk/spec/ruby/core/module/fixtures/autoload_nested.rb trunk/spec/ruby/core/module/fixtures/autoload_raise.rb trunk/spec/ruby/core/module/fixtures/constants_autoload.rb trunk/spec/ruby/core/module/fixtures/constants_autoload_a.rb trunk/spec/ruby/core/module/fixtures/constants_autoload_b.rb trunk/spec/ruby/core/module/fixtures/constants_autoload_c.rb trunk/spec/ruby/core/module/fixtures/constants_autoload_d.rb trunk/spec/ruby/core/signal/fixtures/trap_all.rb trunk/spec/ruby/core/thread/backtrace/location/fixtures/absolute_path.rb trunk/spec/ruby/fixtures/code/load_fixture_and__FILE__.rb trunk/spec/ruby/library/date/iso8601_spec.rb trunk/spec/ruby/library/socket/addrinfo/connect_from_spec.rb trunk/spec/ruby/library/socket/addrinfo/connect_spec.rb trunk/spec/ruby/library/socket/addrinfo/connect_to_spec.rb trunk/spec/ruby/library/socket/addrinfo/family_addrinfo_spec.rb trunk/spec/ruby/library/socket/addrinfo/foreach_spec.rb trunk/spec/ruby/library/socket/addrinfo/getaddrinfo_spec.rb trunk/spec/ruby/library/socket/addrinfo/getnameinfo_spec.rb trunk/spec/ruby/library/socket/addrinfo/inspect_spec.rb trunk/spec/ruby/library/socket/addrinfo/ipv6_linklocal_spec.rb trunk/spec/ruby/library/socket/addrinfo/ipv6_mc_global_spec.rb trunk/spec/ruby/library/socket/addrinfo/ipv6_mc_linklocal_spec.rb trunk/spec/ruby/library/socket/addrinfo/ipv6_mc_nodelocal_spec.rb trunk/spec/ruby/library/socket/addrinfo/ipv6_mc_orglocal_spec.rb trunk/spec/ruby/library/socket/addrinfo/ipv6_mc_sitelocal_spec.rb trunk/spec/ruby/library/socket/addrinfo/ipv6_sitelocal_spec.rb trunk/spec/ruby/library/socket/addrinfo/ipv6_to_ipv4_spec.rb trunk/spec/ruby/library/socket/addrinfo/ipv6_unique_local_spec.rb trunk/spec/ruby/library/socket/addrinfo/ipv6_unspecified_spec.rb trunk/spec/ruby/library/socket/addrinfo/ipv6_v4compat_spec.rb trunk/spec/ruby/library/socket/addrinfo/ipv6_v4mapped_spec.rb trunk/spec/ruby/library/socket/addrinfo/listen_spec.rb trunk/spec/ruby/library/socket/addrinfo/marshal_dump_spec.rb trunk/spec/ruby/library/socket/addrinfo/marshal_load_spec.rb trunk/spec/ruby/library/socket/ancillarydata/cmsg_is_spec.rb trunk/spec/ruby/library/socket/ancillarydata/data_spec.rb trunk/spec/ruby/library/socket/ancillarydata/family_spec.rb trunk/spec/ruby/library/socket/ancillarydata/initialize_spec.rb trunk/spec/ruby/library/socket/ancillarydata/int_spec.rb trunk/spec/ruby/library/socket/ancillarydata/ip_pktinfo_spec.rb trunk/spec/ruby/library/socket/ancillarydata/ipv6_pktinfo_addr_spec.rb trunk/spec/ruby/library/socket/ancillarydata/ipv6_pktinfo_ifindex_spec.rb trunk/spec/ruby/library/socket/ancillarydata/ipv6_pktinfo_spec.rb trunk/spec/ruby/library/socket/ancillarydata/level_spec.rb trunk/spec/ruby/library/socket/ancillarydata/type_spec.rb trunk/spec/ruby/library/socket/ancillarydata/unix_rights_spec.rb trunk/spec/ruby/library/socket/basicsocket/connect_address_spec.rb trunk/spec/ruby/library/socket/basicsocket/getpeereid_spec.rb trunk/spec/ruby/library/socket/basicsocket/recvmsg_nonblock_spec.rb trunk/spec/ruby/library/socket/basicsocket/recvmsg_spec.rb trunk/spec/ruby/library/socket/basicsocket/sendmsg_nonblock_spec.rb trunk/spec/ruby/library/socket/basicsocket/sendmsg_spec.rb trunk/spec/ruby/library/socket/option/initialize_spec.rb trunk/spec/ruby/library/socket/socket/accept_loop_spec.rb trunk/spec/ruby/library/socket/socket/getifaddrs_spec.rb trunk/spec/ruby/library/socket/socket/getservbyport_spec.rb trunk/spec/ruby/library/socket/socket/initialize_spec.rb trunk/spec/ruby/library/socket/socket/ip_address_list_spec.rb trunk/spec/ruby/library/socket/socket/ipv6only_bang_spec.rb trunk/spec/ruby/library/socket/socket/local_address_spec.rb trunk/spec/ruby/library/socket/socket/remote_address_spec.rb trunk/spec/ruby/library/socket/socket/tcp_server_loop_spec.rb trunk/spec/ruby/library/socket/socket/tcp_server_sockets_spec.rb trunk/spec/ruby/library/socket/socket/tcp_spec.rb trunk/spec/ruby/library/socket/socket/udp_server_loop_on_spec.rb trunk/spec/ruby/library/socket/socket/udp_server_loop_spec.rb trunk/spec/ruby/library/socket/socket/udp_server_recv_spec.rb trunk/spec/ruby/library/socket/socket/udp_server_sockets_spec.rb trunk/spec/ruby/library/socket/socket/unix_server_loop_spec.rb trunk/spec/ruby/library/socket/socket/unix_server_socket_spec.rb trunk/spec/ruby/library/socket/socket/unix_spec.rb trunk/spec/ruby/library/socket/spec_helper.rb trunk/spec/ruby/library/socket/tcpserver/initialize_spec.rb trunk/spec/ruby/library/socket/tcpsocket/initialize_spec.rb trunk/spec/ruby/library/socket/tcpsocket/local_address_spec.rb trunk/spec/ruby/library/socket/tcpsocket/recv_spec.rb trunk/spec/ruby/library/socket/tcpsocket/remote_address_spec.rb trunk/spec/ruby/library/socket/udpsocket/connect_spec.rb trunk/spec/ruby/library/socket/udpsocket/initialize_spec.rb trunk/spec/ruby/library/socket/udpsocket/inspect_spec.rb trunk/spec/ruby/library/socket/udpsocket/local_address_spec.rb trunk/spec/ruby/library/socket/udpsocket/recvfrom_nonblock_spec.rb trunk/spec/ruby/library/socket/udpsocket/remote_address_spec.rb trunk/spec/ruby/library/socket/unixserver/initialize_spec.rb trunk/spec/ruby/library/socket/unixserver/listen_spec.rb trunk/spec/ruby/library/socket/unixserver/sysaccept_spec.rb trunk/spec/ruby/library/socket/unixsocket/initialize_spec.rb trunk/spec/ruby/library/socket/unixsocket/local_address_spec.rb trunk/spec/ruby/library/socket/unixsocket/remote_address_spec.rb trunk/spec/ruby/library/socket/unixsocket/socketpair_spec.rb trunk/spec/ruby/library/weakref/allocate_spec.rb trunk/spec/ruby/library/weakref/new_spec.rb trunk/spec/ruby/library/zlib/deflate_spec.rb trunk/spec/ruby/library/zlib/inflate_spec.rb trunk/spec/ruby/security/cve_2010_1330_spec.rb Removed files: trunk/spec/ruby/core/binding/location_spec.rb trunk/spec/ruby/core/kernel/fixtures/autoload_c.rb trunk/spec/ruby/core/module/fixtures/autoload_scope.rb trunk/spec/ruby/library/socket/shared/recv_nonblock.rb Modified files: trunk/spec/ruby/README.md trunk/spec/ruby/command_line/rubyopt_spec.rb trunk/spec/ruby/core/array/reject_spec.rb trunk/spec/ruby/core/binding/eval_spec.rb trunk/spec/ruby/core/binding/fixtures/classes.rb trunk/spec/ruby/core/enumerable/sort_by_spec.rb trunk/spec/ruby/core/io/read_spec.rb trunk/spec/ruby/core/io/shared/write.rb trunk/spec/ruby/core/kernel/__dir___spec.rb trunk/spec/ruby/core/kernel/autoload_spec.rb trunk/spec/ruby/core/kernel/require_relative_spec.rb trunk/spec/ruby/core/kernel/require_spec.rb trunk/spec/ruby/core/kernel/shared/require.rb trunk/spec/ruby/core/module/autoload_spec.rb trunk/spec/ruby/core/module/const_get_spec.rb trunk/spec/ruby/core/module/fixtures/autoload_o.rb trunk/spec/ruby/core/module/initialize_copy_spec.rb trunk/spec/ruby/core/signal/trap_spec.rb trunk/spec/ruby/core/string/force_encoding_spec.rb trunk/spec/ruby/core/thread/backtrace/location/absolute_path_spec.rb trunk/spec/ruby/core/time/localtime_spec.rb trunk/spec/ruby/language/array_spec.rb trunk/spec/ruby/language/constants_spec.rb trunk/spec/ruby/language/fixtures/array.rb trunk/spec/ruby/language/optional_assignments_spec.rb trunk/spec/ruby/library/date/parse_spec.rb trunk/spec/ruby/library/socket/addrinfo/afamily_spec.rb trunk/spec/ruby/library/socket/addrinfo/bind_spec.rb trunk/spec/ruby/library/socket/addrinfo/canonname_spec.rb trunk/spec/ruby/library/socket/addrinfo/initialize_spec.rb trunk/spec/ruby/library/socket/addrinfo/inspect_sockaddr_spec.rb trunk/spec/ruby/library/socket/addrinfo/ip_address_spec.rb trunk/spec/ruby/library/socket/addrinfo/ip_port_spec.rb trunk/spec/ruby/library/socket/addrinfo/ip_spec.rb trunk/spec/ruby/library/socket/addrinfo/ip_unpack_spec.rb trunk/spec/ruby/library/socket/addrinfo/ipv4_loopback_spec.rb trunk/spec/ruby/library/socket/addrinfo/ipv4_multicast_spec.rb trunk/spec/ruby/library/socket/addrinfo/ipv4_private_spec.rb trunk/spec/ruby/library/socket/addrinfo/ipv4_spec.rb trunk/spec/ruby/library/socket/addrinfo/ipv6_loopback_spec.rb trunk/spec/ruby/library/socket/addrinfo/ipv6_multicast_spec.rb trunk/spec/ruby/library/socket/addrinfo/ipv6_spec.rb trunk/spec/ruby/library/socket/addrinfo/pfamily_spec.rb trunk/spec/ruby/library/socket/addrinfo/protocol_spec.rb trunk/spec/ruby/library/socket/addrinfo/shared/to_sockaddr.rb trunk/spec/ruby/library/socket/addrinfo/socktype_spec.rb trunk/spec/ruby/library/socket/addrinfo/tcp_spec.rb trunk/spec/ruby/library/socket/addrinfo/to_s_spec.rb trunk/spec/ruby/library/socket/addrinfo/to_sockaddr_spec.rb trunk/spec/ruby/library/socket/addrinfo/udp_spec.rb trunk/spec/ruby/library/socket/addrinfo/unix_path_spec.rb trunk/spec/ruby/library/socket/addrinfo/unix_spec.rb trunk/spec/ruby/library/socket/basicsocket/close_read_spec.rb trunk/spec/ruby/library/socket/basicsocket/close_write_spec.rb trunk/spec/ruby/library/socket/basicsocket/do_not_reverse_lookup_spec.rb trunk/spec/ruby/library/socket/basicsocket/for_fd_spec.rb trunk/spec/ruby/library/socket/basicsocket/getpeername_spec.rb trunk/spec/ruby/library/socket/basicsocket/getsockname_spec.rb trunk/spec/ruby/library/socket/basicsocket/getsockopt_spec.rb trunk/spec/ruby/library/socket/basicsocket/ioctl_spec.rb trunk/spec/ruby/library/socket/basicsocket/recv_nonblock_spec.rb trunk/spec/ruby/library/socket/basicsocket/recv_spec.rb trunk/spec/ruby/library/socket/basicsocket/send_spec.rb trunk/spec/ruby/library/socket/basicsocket/setsockopt_spec.rb trunk/spec/ruby/library/socket/basicsocket/shutdown_spec.rb trunk/spec/ruby/library/socket/constants/constants_spec.rb trunk/spec/ruby/library/socket/fixtures/classes.rb trunk/spec/ruby/library/socket/ipsocket/addr_spec.rb trunk/spec/ruby/library/socket/ipsocket/getaddress_spec.rb trunk/spec/ruby/library/socket/ipsocket/peeraddr_spec.rb trunk/spec/ruby/library/socket/ipsocket/recvfrom_spec.rb trunk/spec/ruby/library/socket/option/bool_spec.rb trunk/spec/ruby/library/socket/option/inspect_spec.rb trunk/spec/ruby/library/socket/option/int_spec.rb trunk/spec/ruby/library/socket/option/linger_spec.rb trunk/spec/ruby/library/socket/option/new_spec.rb trunk/spec/ruby/library/socket/shared/pack_sockaddr.rb trunk/spec/ruby/library/socket/shared/socketpair.rb trunk/spec/ruby/library/socket/socket/accept_nonblock_spec.rb trunk/spec/ruby/library/socket/socket/accept_spec.rb trunk/spec/ruby/library/socket/socket/bind_spec.rb trunk/spec/ruby/library/socket/socket/connect_nonblock_spec.rb trunk/spec/ruby/library/socket/socket/connect_spec.rb trunk/spec/ruby/library/socket/socket/for_fd_spec.rb trunk/spec/ruby/library/socket/socket/getaddrinfo_spec.rb trunk/spec/ruby/library/socket/socket/gethostbyaddr_spec.rb trunk/spec/ruby/library/socket/socket/gethostbyname_spec.rb trunk/spec/ruby/library/socket/socket/gethostname_spec.rb trunk/spec/ruby/library/socket/socket/getnameinfo_spec.rb trunk/spec/ruby/library/socket/socket/getservbyname_spec.rb trunk/spec/ruby/library/socket/socket/listen_spec.rb trunk/spec/ruby/library/socket/socket/new_spec.rb trunk/spec/ruby/library/socket/socket/pack_sockaddr_in_spec.rb trunk/spec/ruby/library/socket/socket/pack_sockaddr_un_spec.rb trunk/spec/ruby/library/socket/socket/pair_spec.rb trunk/spec/ruby/library/socket/socket/recvfrom_nonblock_spec.rb trunk/spec/ruby/library/socket/socket/recvfrom_spec.rb trunk/spec/ruby/library/socket/socket/sockaddr_in_spec.rb trunk/spec/ruby/library/socket/socket/sockaddr_un_spec.rb trunk/spec/ruby/library/socket/socket/socket_spec.rb trunk/spec/ruby/library/socket/socket/socketpair_spec.rb trunk/spec/ruby/library/socket/socket/sysaccept_spec.rb trunk/spec/ruby/library/socket/socket/unpack_sockaddr_in_spec.rb trunk/spec/ruby/library/socket/socket/unpack_sockaddr_un_spec.rb trunk/spec/ruby/library/socket/tcpserver/accept_nonblock_spec.rb trunk/spec/ruby/library/socket/tcpserver/accept_spec.rb trunk/spec/ruby/library/socket/tcpserver/gets_spec.rb trunk/spec/ruby/library/socket/tcpserver/listen_spec.rb trunk/spec/ruby/library/socket/tcpserver/new_spec.rb trunk/spec/ruby/library/socket/tcpserver/sysaccept_spec.rb trunk/spec/ruby/library/socket/tcpsocket/gethostbyname_spec.rb trunk/spec/ruby/library/socket/tcpsocket/partially_closable_spec.rb trunk/spec/ruby/library/socket/tcpsocket/recv_nonblock_spec.rb trunk/spec/ruby/library/socket/tcpsocket/setsockopt_spec.rb trunk/spec/ruby/library/socket/tcpsocket/shared/new.rb trunk/spec/ruby/library/socket/udpsocket/bind_spec.rb trunk/spec/ruby/library/socket/udpsocket/new_spec.rb trunk/spec/ruby/library/socket/udpsocket/open_spec.rb trunk/spec/ruby/library/socket/udpsocket/send_spec.rb trunk/spec/ruby/library/socket/udpsocket/write_spec.rb trunk/spec/ruby/library/socket/unixserver/accept_nonblock_spec.rb trunk/spec/ruby/library/socket/unixserver/accept_spec.rb trunk/spec/ruby/library/socket/unixserver/for_fd_spec.rb trunk/spec/ruby/library/socket/unixserver/new_spec.rb trunk/spec/ruby/library/socket/unixserver/open_spec.rb trunk/spec/ruby/library/socket/unixserver/shared/new.rb trunk/spec/ruby/library/socket/unixsocket/addr_spec.rb trunk/spec/ruby/library/socket/unixsocket/inspect_spec.rb trunk/spec/ruby/library/socket/unixsocket/new_spec.rb trunk/spec/ruby/library/socket/unixsocket/open_spec.rb trunk/spec/ruby/library/socket/unixsocket/pair_spec.rb trunk/spec/ruby/library/socket/unixsocket/partially_closable_spec.rb trunk/spec/ruby/library/socket/unixsocket/path_spec.rb trunk/spec/ruby/library/socket/unixsocket/peeraddr_spec.rb trunk/spec/ruby/library/socket/unixsocket/recv_io_spec.rb trunk/spec/ruby/library/socket/unixsocket/recvfrom_spec.rb trunk/spec/ruby/library/socket/unixsocket/send_io_spec.rb trunk/spec/ruby/library/socket/unixsocket/shared/new.rb trunk/spec/ruby/library/zlib/deflate/deflate_spec.rb trunk/spec/ruby/optional/capi/encoding_spec.rb trunk/spec/ruby/optional/capi/ext/encoding_spec.c trunk/spec/ruby/optional/capi/ext/rubyspec.h trunk/spec/ruby/optional/capi/module_spec.rb Index: spec/ruby/core/module/fixtures/autoload_scope.rb =================================================================== --- spec/ruby/core/module/fixtures/autoload_scope.rb (revision 64179) +++ spec/ruby/core/module/fixtures/autoload_scope.rb (nonexistent) @@ -1,8 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/module/fixtures/autoload_scope.rb#L0 -module ModuleSpecs - module Autoload - class PP - class QQ - end - end - end -end Property changes on: spec/ruby/core/module/fixtures/autoload_scope.rb ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -LF \ No newline at end of property Index: spec/ruby/core/kernel/fixtures/autoload_c.rb =================================================================== --- spec/ruby/core/kernel/fixtures/autoload_c.rb (revision 64179) +++ spec/ruby/core/kernel/fixtures/autoload_c.rb (nonexistent) @@ -1,5 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/kernel/fixtures/autoload_c.rb#L0 -module KSAutoloadC - def self.loaded - :ksautoload_c - end -end Property changes on: spec/ruby/core/kernel/fixtures/autoload_c.rb ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -LF \ No newline at end of property Index: spec/ruby/core/binding/location_spec.rb =================================================================== --- spec/ruby/core/binding/location_spec.rb (revision 64179) +++ spec/ruby/core/binding/location_spec.rb (nonexistent) @@ -1,46 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/binding/location_spec.rb#L0 -require_relative '../../spec_helper' -require_relative 'fixtures/classes' - -describe "Binding#eval" do - it "inherits __LINE__ from the enclosing scope" do - obj = BindingSpecs::Demo.new(1) - bind = obj.get_binding - bind.eval("__LINE__").should == obj.get_line_of_binding - end - - it "preserves __LINE__ across multiple calls to eval" do - obj = BindingSpecs::Demo.new(1) - bind = obj.get_binding - bind.eval("__LINE__").should == obj.get_line_of_binding - bind.eval("__LINE__").should == obj.get_line_of_binding - end - - it "increments __LINE__ on each line of a multiline eval" do - obj = BindingSpecs::Demo.new(1) - bind = obj.get_binding - bind.eval("#foo\n__LINE__").should == obj.get_line_of_binding + 1 - end - - it "starts with a __LINE__ of 1 if a filename is passed" do - bind = BindingSpecs::Demo.new(1).get_binding - bind.eval("__LINE__", "(test)").should == 1 - bind.eval("#foo\n__LINE__", "(test)").should == 2 - end - - it "starts with a __LINE__ from the third argument if passed" do - bind = BindingSpecs::Demo.new(1).get_binding - bind.eval("__LINE__", "(test)", 88).should == 88 - bind.eval("#foo\n__LINE__", "(test)", 88).should == 89 - end - - it "inherits __FILE__ from the enclosing scope" do - obj = BindingSpecs::Demo.new(1) - bind = obj.get_binding - bind.eval("__FILE__").should == obj.get_file_of_binding - end - - it "uses the __FILE__ that is passed in" do - bind = BindingSpecs::Demo.new(1).get_binding - bind.eval("__FILE__", "(test)").should == "(test)" - end -end Property changes on: spec/ruby/core/binding/location_spec.rb ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -LF \ No newline at end of property Index: spec/ruby/core/binding/fixtures/classes.rb =================================================================== --- spec/ruby/core/binding/fixtures/classes.rb (revision 64179) +++ spec/ruby/core/binding/fixtures/classes.rb (revision 64180) @@ -25,6 +25,18 @@ module BindingSpecs https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/binding/fixtures/classes.rb#L25 __FILE__ end + def get_binding_with_send_and_line + [send(:binding), __LINE__] + end + + def get_binding_and_method + [binding, :get_binding_and_method] + end + + def get_binding_with_send_and_method + [send(:binding), :get_binding_with_send_and_method] + end + def get_empty_binding binding end Index: spec/ruby/README.md =================================================================== --- spec/ruby/README.md (revision 64179) +++ spec/ruby/README.md (revision 64180) @@ -92,6 +92,13 @@ In similar fashion, the following comman https://github.com/ruby/ruby/blob/trunk/spec/ruby/README.md#L92 See [CONTRIBUTING.md](https://github.com/ruby/spec/blob/master/CONTRIBUTING.md). +### Socket specs from rubysl-socket + +Most specs under `library/socket` were imported from [the rubysl-socket project](https://github.com/rubysl/rubysl-socket). +The 3 copyright holders of rubysl-socket, Yorick Peterse, Chuck Remes and +Brian Shirai, [agreed to relicense those specs](https://github.com/rubysl/rubysl-socket/issues/15) +under the MIT license in ruby/spec. + ### History and RubySpec This project was originally born from [Rubinius](https://github.com/rubinius/rubinius) tests being converted to the spec style. Index: spec/ruby/library/socket/addrinfo/getaddrinfo_spec.rb =================================================================== --- spec/ruby/library/socket/addrinfo/getaddrinfo_spec.rb (nonexistent) +++ spec/ruby/library/socket/addrinfo/getaddrinfo_spec.rb (revision 64180) @@ -0,0 +1,88 @@ https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/socket/addrinfo/getaddrinfo_spec.rb#L1 +require_relative '../spec_helper' +require_relative '../fixtures/classes' + +describe 'Addrinfo.getaddrinfo' do + it 'returns an Array of Addrinfo instances' do + array = Addrinfo.getaddrinfo('localhost', 80) + + array.should be_an_instance_of(Array) + array[0].should be_an_instance_of(Addrinfo) + end + + SocketSpecs.each_ip_protocol do |family, ip_address| + it 'sets the IP address of the Addrinfo instances' do + array = Addrinfo.getaddrinfo(ip_address, 80) + + array[0].ip_address.should == ip_address + end + + it 'sets the port of the Addrinfo instances' do + array = Addrinfo.getaddrinfo(ip_address, 80) + + array[0].ip_port.should == 80 + end + + it 'sets the address family of the Addrinfo instances' do + array = Addrinfo.getaddrinfo(ip_address, 80) + + array[0].afamily.should == family + end + + it 'sets the protocol family of the Addrinfo instances' do + array = Addrinfo.getaddrinfo(ip_address, 80) + + array[0].pfamily.should == family + end + end + + guard -> { SocketSpecs.ipv6_available? } do + it 'sets a custom protocol family of the Addrinfo instances' do + array = Addrinfo.getaddrinfo('localhost', 80, Socket::PF_INET6) + + array[0].pfamily.should == Socket::PF_INET6 + end + + it 'sets a corresponding address family based on a custom protocol family' do + array = Addrinfo.getaddrinfo('localhost', 80, Socket::PF_INET6) + + array[0].afamily.should == Socket::AF_INET6 + end + end + + platform_is_not :windows do + it 'sets the default socket type of the Addrinfo instances' do + array = Addrinfo.getaddrinfo('localhost', 80) + possible = [Socket::SOCK_STREAM, Socket::SOCK_DGRAM] + + possible.should include(array[0].socktype) + end + end + + it 'sets a custom socket type of the Addrinfo instances' do + array = Addrinfo.getaddrinfo('localhost', 80, nil, Socket::SOCK_DGRAM) + + array[0].socktype.should == Socket::SOCK_DGRAM + end + + platform_is_not :windows do + it 'sets the default socket protocol of the Addrinfo instances' do + array = Addrinfo.getaddrinfo('localhost', 80) + possible = [Socket::IPPROTO_TCP, Socket::IPPROTO_UDP] + + possible.should include(array[0].protocol) + end + end + + it 'sets a custom socket protocol of the Addrinfo instances' do + array = Addrinfo.getaddrinfo('localhost', 80, nil, nil, Socket::IPPROTO_UDP) + + array[0].protocol.should == Socket::IPPROTO_UDP + end + + it 'sets the canonical name when AI_CANONNAME is given as a flag' do + array = Addrinfo + .getaddrinfo('localhost', 80, nil, nil, nil, Socket::AI_CANONNAME) + + array[0].canonname.should be_an_instance_of(String) + end +end Property changes on: spec/ruby/library/socket/addrinfo/getaddrinfo_spec.rb ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +LF \ No newline at end of property Index: spec/ruby/library/socket/addrinfo/shared/to_sockaddr.rb =================================================================== --- spec/ruby/library/socket/addrinfo/shared/to_sockaddr.rb (revision 64179) +++ spec/ruby/library/socket/addrinfo/shared/to_sockaddr.rb (revision 64180) @@ -6,7 +6,7 @@ describe :socket_addrinfo_to_sockaddr, : https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/socket/addrinfo/shared/to_sockaddr.rb#L6 end it "returns a sockaddr packed structure" do - @addrinfo.send(@method).should be_kind_of(String) + @addrinfo.send(@method).should == Socket.sockaddr_in(80, '127.0.0.1') end end @@ -16,20 +16,36 @@ describe :socket_addrinfo_to_sockaddr, : https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/socket/addrinfo/shared/to_sockaddr.rb#L16 end it "returns a sockaddr packed structure" do - @addrinfo.send(@method).should be_kind_of(String) + @addrinfo.send(@method).should == Socket.sockaddr_in(80, '::1') end end - platform_is_not :windows do + with_feature :unix_socket do describe "for a unix socket" do before :each do @addrinfo = Addrinfo.unix("/tmp/sock") end it "returns a sockaddr packed structure" do - @addrinfo.send(@method).should be_kind_of(String) + @addrinfo.send(@method).should == Socket.sockaddr_un('/tmp/sock') end end end + describe 'using a Addrinfo with just an IP address' do + it 'returns a String' do + addr = Addrinfo.ip('127.0.0.1') + + addr.send(@method).should == Socket.sockaddr_in(0, '127.0.0.1') + end + end + + describe 'using a Addrinfo without an IP and port' do + it 'returns a String' do + addr = Addrinfo.new(['AF_INET', 0, '', '']) + + addr.send(@method).should == Socket.sockaddr_in(0, '') + end + end + end Index: spec/ruby/library/socket/addrinfo/listen_spec.rb =================================================================== --- spec/ruby/library/socket/addrinfo/listen_spec.rb (nonexistent) +++ spec/ruby/library/socket/addrinfo/listen_spec.rb (revision 64180) @@ -0,0 +1,34 @@ https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/socket/addrinfo/listen_spec.rb#L1 +require_relative '../spec_helper' + +describe 'Addrinfo#listen' do + before do + @addr = Addrinfo.tcp('127.0.0.1', 0) + @socket = nil + end + + after do + @socket.close if @socket + end + + it 'returns a Socket when no block is given' do + @socket = @addr.listen + + @socket.should be_an_instance_of(Socket) + end + + it 'yields the Socket if a block is given' do + @addr.listen do |socket| + socket.should be_an_instance_of(Socket) + end + end + + it 'closes the socket if a block is given' do + socket = nil + + @addr.listen do |sock| + socket = sock + end + + socket.closed?.should == true + end +end Property changes on: spec/ruby/library/socket/addrinfo/listen_spec.rb ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +LF \ No newline at end of property Index: spec/ruby/core/kernel/require_relative_spec.rb =================================================================== --- spec/ruby/core/kernel/require_relative_spec.rb (revision 64179) +++ spec/ruby/core/kernel/require_relative_spec.rb (revision 64180) @@ -199,6 +199,46 @@ describe "Kernel#require_relative with a https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/kernel/require_relative_spec.rb#L199 $LOADED_FEATURES.should include(@abs_path) end + platform_is_not :windows do + describe "with symlinks" do + before :each do + @symlink_to_code_dir = tmp("codesymlink") + File.symlink(CODE_LOADING_DIR, @symlink_to_code_dir) + @symlink_basename = File.basename(@symlink_to_code_dir) + @requiring_file = tmp("requiring") + end + + after :each do + rm_r @symlink_to_code_dir, @requiring_file + end + + it "does not canonicalize the path and stores a path with symlinks" do + symlink_path = "#{@symlink_basename}/load_fixture.rb" + absolute_path = "#{tmp("")}#{symlink_path}" + canonical_path = "#{CODE_LOADING_DIR}/load_fixture.rb" + touch(@requiring_file) { |f| + f.puts "require_relative #{symlink_path.inspect}" + } + load(@requiring_file) + ScratchPad.recorded.should == [:loaded] + + features = $LOADED_FEATURES.select { |path| path.end_with?('load_fixture.rb') } + features.should include(absolute_path) + features.should_not include(canonical_path) + end + + it "stores the same path that __FILE__ returns in the required file" do + symlink_path = "#{@symlink_basename}/load_fixture_and__FILE__.rb" + touch(@requiring_file) { |f| + f.puts "require_relative #{symlink_path.inspect}" + } + load(@requiring_file) + loaded_feature = $LOADED_FEATURES.last + ScratchPad.recorded.should == [loaded_feature] + end + end + end + it "does not store the path if the load fails" do saved_loaded_features = $LOADED_FEATURES.dup lambda { require_relative("#{@dir}/raise_fixture.rb") }.should raise_error(RuntimeError) Index: spec/ruby/core/kernel/__dir___spec.rb =================================================================== --- spec/ruby/core/kernel/__dir___spec.rb (revision 64179) +++ spec/ruby/core/kernel/__dir___spec.rb (revision 64180) @@ -5,6 +5,13 @@ describe "Kernel#__dir__" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/kernel/__dir___spec.rb#L5 __dir__.should == File.realpath(File.dirname(__FILE__)) end + context "when used in eval with a given filename" do + it "returns File.dirname(filename)" do + eval("__dir__", nil, "foo.rb").should == "." + eval("__dir__", nil, "foo/bar.rb").should == "foo" + end + end + context "when used in eval with top level binding" do it "returns the real name of the directory containing the currently-executing file" do eval("__dir__", binding).should == File.realpath(File.dirname(__FILE__)) Index: spec/ruby/core/kernel/require_spec.rb =================================================================== --- spec/ruby/core/kernel/require_spec.rb (revision 64179) +++ spec/ruby/core/kernel/require_spec.rb (revision 64180) @@ -17,7 +17,6 @@ describe "Kernel#require" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/kernel/require_spec.rb#L17 end it_behaves_like :kernel_require_basic, :require, CodeLoadingSpecs::Method.new - it_behaves_like :kernel_require, :require, CodeLoadingSpecs::Method.new end @@ -31,6 +30,5 @@ describe "Kernel.require" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/kernel/require_spec.rb#L30 end it_behaves_like :kernel_require_basic, :require, Kernel - it_behaves_like :kernel_require, :require, Kernel end Index: spec/ruby/core/thread/backtrace/location/absolute_path_spec.rb =================================================================== --- spec/ruby/core/thread/backtrace/location/absolute_path_spec.rb (revision 64179) +++ spec/ruby/core/thread/backtrace/location/absolute_path_spec.rb (revision 64180) @@ -9,4 +9,42 @@ describe 'Thread::Backtrace::Location#ab https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/thread/backtrace/location/absolute_path_spec.rb#L9 it 'returns the absolute path of the call frame' do @frame.absolute_path.should == File.realpath(__FILE__) end + + context "when used in eval with a given filename" do + it "returns filename" do + code = "caller_locations(0)[0].absolute_path" + eval(code, nil, "foo.rb").should == "foo.rb" + eval(code, nil, "foo/bar.rb").should == "foo/bar.rb" + end + end + + platform_is_not :windows do + before :each do + @file = fixture(__FILE__, "absolute_path.rb") + @symlink = tmp("symlink.rb") + File.symlink(@file, @symlink) + ScratchPad.record [] + end + + after :each do + rm_r @symlink + end + + it "returns a canonical path without symlinks, even when __FILE__ does not" do + realpath = File.realpath(@symlink) + realpath.should_not == @symlink + + load @symlink + ScratchPad.recorded.should == [@symlink, realpath] + end + + it "returns a canonical path without symlinks, even when __FILE__ is removed" do + realpath = File.realpath(@symlink) + realpath.should_not == @symlink + + ScratchPad << -> { rm_r(@symlink) } + load @symlink + ScratchPad.recorded.should == [@symlink, realpath] + end + end end Index: spec/ruby/core/binding/eval_spec.rb =================================================================== --- spec/ruby/core/binding/eval_spec.rb (revision 64179) +++ spec/ruby/core/binding/eval_spec.rb (revision 64180) @@ -23,6 +23,54 @@ describe "Binding#eval" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/binding/eval_spec.rb#L23 bind2.local_variables.should == [] end + it "inherits __LINE__ from the enclosing scope" do + obj = BindingSpecs::Demo.new(1) + bind = obj.get_binding + bind.eval("__LINE__").should == obj.get_line_of_binding + end + + it "preserves __LINE__ across multiple calls to eval" do + obj = BindingSpecs::Demo.new(1) + bind = obj.get_binding + bind.eval("__LINE__").should == obj.get_line_of_binding + bind.eval("__LINE__").should == obj.get_line_of_binding + end + + it "increments __LINE__ on each line of a multiline eval" do + obj = BindingSpecs::Demo.new(1) + bind = obj.get_binding + bind.eval("#foo\n__LINE__").should == obj.get_line_of_binding + 1 + end + + it "inherits __LINE__ from the enclosing scope even if the Binding is created with #send" do + obj = BindingSpecs::Demo.new(1) + bind, line = obj.get_binding_with_send_and_line + bind.eval("__LINE__").should == line + end + + it "starts with a __LINE__ of 1 if a filename is passed" do + bind = BindingSpecs::Demo.new(1).get_binding + bind.eval("__LINE__", "(test)").should == 1 + bind.eval("#foo\n__LINE__", "(test)").should == 2 + end + + it "starts with a __LINE__ from the third argument if passed" do + bind = BindingSpecs::Demo.new(1).get_binding + bind.eval("__LINE__", "(test)", 88).should == 88 + bind.eval("#foo\n__LINE__", "(test)", 88).should == 89 + end + + it "inherits __FILE__ from the enclosing scope" do + obj = BindingSpecs::Demo.new(1) + bind = obj.get_binding + bind.eval("__FILE__").should == obj.get_file_of_binding + end + + it "uses the __FILE__ that is passed in" do + bind = BindingSpecs::Demo.new(1).get_binding + bind.eval("__FILE__", "(test)").should == "(test)" + end + describe "with a file given" do it "does not store the filename permanently" do obj = BindingSpecs::Demo.new(1) @@ -33,5 +81,15 @@ describe "Binding#eval" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/binding/eval_spec.rb#L81 end end - it "needs to be reviewed for spec completeness" + it "with __method__ returns the method where the Binding was created" do + obj = BindingSpecs::Demo.new(1) + bind, meth = obj.get_binding_and_method + bind.eval("__method__").should == meth + end + + it "with __method__ returns the method where the Binding was created, ignoring #send" do + obj = BindingSpecs::Demo.new(1) + bind, meth = obj.get_binding_with_send_and_method + bind.eval("__met (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/