ruby-changes:46602
From: eregon <ko1@a...>
Date: Sun, 14 May 2017 23:10:02 +0900 (JST)
Subject: [ruby-changes:46602] eregon:r58718 (trunk): Update to ruby/spec@032022ca
eregon 2017-05-14 23:09:56 +0900 (Sun, 14 May 2017) New Revision: 58718 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=58718 Log: Update to ruby/spec@032022ca Added directories: trunk/spec/rubyspec/command_line/fixtures/bin/ Added files: trunk/spec/rubyspec/command_line/dash_upper_s_spec.rb trunk/spec/rubyspec/command_line/fixtures/bin/bad_embedded_ruby.txt trunk/spec/rubyspec/command_line/fixtures/bin/embedded_ruby.txt trunk/spec/rubyspec/command_line/fixtures/bin/hybrid_launcher.sh trunk/spec/rubyspec/command_line/fixtures/bin/launcher.rb Removed files: trunk/spec/rubyspec/command_line/fixtures/embedded_ruby.txt Modified files: trunk/spec/rubyspec/command_line/dash_x_spec.rb trunk/spec/rubyspec/core/bignum/bit_and_spec.rb trunk/spec/rubyspec/core/binding/eval_spec.rb trunk/spec/rubyspec/core/binding/fixtures/classes.rb trunk/spec/rubyspec/core/binding/local_variable_get_spec.rb trunk/spec/rubyspec/core/binding/local_variable_set_spec.rb trunk/spec/rubyspec/core/binding/shared/clone.rb trunk/spec/rubyspec/core/fiber/yield_spec.rb trunk/spec/rubyspec/core/file/fixtures/file_types.rb trunk/spec/rubyspec/core/file/ftype_spec.rb trunk/spec/rubyspec/core/file/stat/ftype_spec.rb trunk/spec/rubyspec/core/fixnum/bit_and_spec.rb trunk/spec/rubyspec/core/io/advise_spec.rb trunk/spec/rubyspec/core/process/exec_spec.rb trunk/spec/rubyspec/core/process/spawn_spec.rb trunk/spec/rubyspec/core/time/minus_spec.rb trunk/spec/rubyspec/language/block_spec.rb trunk/spec/rubyspec/language/defined_spec.rb trunk/spec/rubyspec/language/heredoc_spec.rb trunk/spec/rubyspec/language/regexp/character_classes_spec.rb trunk/spec/rubyspec/language/regexp_spec.rb trunk/spec/rubyspec/language/variables_spec.rb trunk/spec/rubyspec/language/while_spec.rb trunk/spec/rubyspec/library/socket/fixtures/classes.rb trunk/spec/rubyspec/library/socket/unixserver/accept_nonblock_spec.rb trunk/spec/rubyspec/library/socket/unixserver/accept_spec.rb trunk/spec/rubyspec/library/socket/unixserver/for_fd_spec.rb trunk/spec/rubyspec/library/socket/unixserver/open_spec.rb trunk/spec/rubyspec/library/socket/unixserver/shared/new.rb trunk/spec/rubyspec/library/socket/unixsocket/addr_spec.rb trunk/spec/rubyspec/library/socket/unixsocket/open_spec.rb trunk/spec/rubyspec/library/socket/unixsocket/partially_closable_spec.rb trunk/spec/rubyspec/library/socket/unixsocket/path_spec.rb trunk/spec/rubyspec/library/socket/unixsocket/peeraddr_spec.rb trunk/spec/rubyspec/library/socket/unixsocket/recv_io_spec.rb trunk/spec/rubyspec/library/socket/unixsocket/recvfrom_spec.rb trunk/spec/rubyspec/library/socket/unixsocket/send_io_spec.rb trunk/spec/rubyspec/library/socket/unixsocket/shared/new.rb trunk/spec/rubyspec/optional/capi/bignum_spec.rb trunk/spec/rubyspec/optional/capi/mutex_spec.rb trunk/spec/rubyspec/optional/capi/spec_helper.rb trunk/spec/rubyspec/shared/time/strftime_for_date.rb Index: spec/rubyspec/command_line/fixtures/embedded_ruby.txt =================================================================== --- spec/rubyspec/command_line/fixtures/embedded_ruby.txt (revision 58717) +++ spec/rubyspec/command_line/fixtures/embedded_ruby.txt (nonexistent) @@ -1,3 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/command_line/fixtures/embedded_ruby.txt#L0 -@@@This line is not value Ruby -#!ruby -puts 'success' \ No newline at end of file Index: spec/rubyspec/core/time/minus_spec.rb =================================================================== --- spec/rubyspec/core/time/minus_spec.rb (revision 58717) +++ spec/rubyspec/core/time/minus_spec.rb (revision 58718) @@ -41,7 +41,7 @@ describe "Time#-" do https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/core/time/minus_spec.rb#L41 time.usec.should == 123456 end - it "tracks microseconds" do + it "tracks microseconds from a Rational" do time = Time.at(Rational(777_777, 1_000_000)) time -= Rational(654_321, 1_000_000) time.usec.should == 123_456 @@ -63,12 +63,12 @@ describe "Time#-" do https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/core/time/minus_spec.rb#L63 end it "maintains microseconds precision" do - time = Time.at(10) - Rational(1_000_000_000_000_001, 1_000_000_000_000_000) + time = Time.at(10) - Rational(1, 1_000_000) time.usec.should == 999_999 end it "maintains nanoseconds precision" do - time = Time.at(10) - Rational(1_000_000_000_000_001, 1_000_000_000_000_000) + time = Time.at(10) - Rational(1, 1_000_000_000) time.nsec.should == 999_999_999 end Index: spec/rubyspec/core/binding/local_variable_get_spec.rb =================================================================== --- spec/rubyspec/core/binding/local_variable_get_spec.rb (revision 58717) +++ spec/rubyspec/core/binding/local_variable_get_spec.rb (revision 58718) @@ -42,4 +42,15 @@ describe "Binding#local_variable_get" do https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/core/binding/local_variable_get_spec.rb#L42 bind.local_variable_get(:number).should == 10 end + + it "raises a NameError on global access" do + bind = binding + lambda { bind.local_variable_get(:$0) }.should raise_error(NameError) + end + + it "raises a NameError on special variable access" do + bind = binding + lambda { bind.local_variable_get(:$~) }.should raise_error(NameError) + lambda { bind.local_variable_get(:$_) }.should raise_error(NameError) + end end Index: spec/rubyspec/core/binding/local_variable_set_spec.rb =================================================================== --- spec/rubyspec/core/binding/local_variable_set_spec.rb (revision 58717) +++ spec/rubyspec/core/binding/local_variable_set_spec.rb (revision 58718) @@ -56,4 +56,16 @@ describe "Binding#local_variable_set" do https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/core/binding/local_variable_set_spec.rb#L56 bind.local_variable_set(:number, 20) bind.local_variable_get(:number).should == 20 end + + it "raises a NameError on global access" do + bind = binding + lambda { bind.local_variable_set(:$0, "") }.should raise_error(NameError) + end + + it "raises a NameError on special variable access" do + bind = binding + lambda { bind.local_variable_set(:$~, "") }.should raise_error(NameError) + lambda { bind.local_variable_set(:$_, "") }.should raise_error(NameError) + end + end Index: spec/rubyspec/library/socket/fixtures/classes.rb =================================================================== --- spec/rubyspec/library/socket/fixtures/classes.rb (revision 58717) +++ spec/rubyspec/library/socket/fixtures/classes.rb (revision 58718) @@ -51,7 +51,18 @@ module SocketSpecs https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/library/socket/fixtures/classes.rb#L51 end def self.socket_path - tmp("unix_server_spec.socket", false) + path = tmp("unix.sock", false) + # Check for too long unix socket path (max 108 bytes including \0 => 107) + # Note that Linux accepts not null-terminated paths but the man page advises against it. + if path.bytesize > 107 + path = "/tmp/unix_server_spec.socket" + end + rm_socket(path) + path + end + + def self.rm_socket(path) + File.delete(path) if File.exist?(path) end # TCPServer echo server accepting one connection Index: spec/rubyspec/library/socket/unixserver/accept_spec.rb =================================================================== --- spec/rubyspec/library/socket/unixserver/accept_spec.rb (revision 58717) +++ spec/rubyspec/library/socket/unixserver/accept_spec.rb (revision 58718) @@ -5,16 +5,15 @@ platform_is_not :windows do https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/library/socket/unixserver/accept_spec.rb#L5 describe "UNIXServer#accept" do before :each do @path = SocketSpecs.socket_path - rm_r @path end after :each do - rm_r @path + SocketSpecs.rm_socket @path end it "accepts what is written by the client" do - server = UNIXServer.open(SocketSpecs.socket_path) - client = UNIXSocket.open(SocketSpecs.socket_path) + server = UNIXServer.open(@path) + client = UNIXSocket.open(@path) client.send('hello', 0) Index: spec/rubyspec/library/socket/unixserver/accept_nonblock_spec.rb =================================================================== --- spec/rubyspec/library/socket/unixserver/accept_nonblock_spec.rb (revision 58717) +++ spec/rubyspec/library/socket/unixserver/accept_nonblock_spec.rb (revision 58718) @@ -6,8 +6,6 @@ describe "UNIXServer#accept_nonblock" do https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/library/socket/unixserver/accept_nonblock_spec.rb#L6 platform_is_not :windows do before :each do @path = SocketSpecs.socket_path - rm_r @path - @server = UNIXServer.open(@path) @client = UNIXSocket.open(@path) @@ -19,7 +17,7 @@ describe "UNIXServer#accept_nonblock" do https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/library/socket/unixserver/accept_nonblock_spec.rb#L17 @socket.close @client.close @server.close - rm_r @path + SocketSpecs.rm_socket @path end it "accepts a connection in a non-blocking way" do Index: spec/rubyspec/library/socket/unixsocket/recvfrom_spec.rb =================================================================== --- spec/rubyspec/library/socket/unixsocket/recvfrom_spec.rb (revision 58717) +++ spec/rubyspec/library/socket/unixsocket/recvfrom_spec.rb (revision 58718) @@ -6,8 +6,6 @@ describe "UNIXSocket#recvfrom" do https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/library/socket/unixsocket/recvfrom_spec.rb#L6 platform_is_not :windows do before :each do @path = SocketSpecs.socket_path - rm_r @path - @server = UNIXServer.open(@path) @client = UNIXSocket.open(@path) end @@ -15,7 +13,7 @@ describe "UNIXSocket#recvfrom" do https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/library/socket/unixsocket/recvfrom_spec.rb#L13 after :each do @client.close @server.close - rm_r @path + SocketSpecs.rm_socket @path end it "receives len bytes from sock" do Index: spec/rubyspec/library/socket/unixsocket/recv_io_spec.rb =================================================================== --- spec/rubyspec/library/socket/unixsocket/recv_io_spec.rb (revision 58717) +++ spec/rubyspec/library/socket/unixsocket/recv_io_spec.rb (revision 58718) @@ -20,7 +20,7 @@ describe "UNIXSocket#recv_io" do https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/library/socket/unixsocket/recv_io_spec.rb#L20 @file.close @client.close @server.close - rm_r @path + SocketSpecs.rm_socket @path end it "reads an IO object across the socket" do Index: spec/rubyspec/library/socket/unixsocket/path_spec.rb =================================================================== --- spec/rubyspec/library/socket/unixsocket/path_spec.rb (revision 58717) +++ spec/rubyspec/library/socket/unixsocket/path_spec.rb (revision 58718) @@ -6,8 +6,6 @@ describe "UNIXSocket#path" do https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/library/socket/unixsocket/path_spec.rb#L6 platform_is_not :windows do before :each do @path = SocketSpecs.socket_path - rm_r @path - @server = UNIXServer.open(@path) @client = UNIXSocket.open(@path) end @@ -15,7 +13,7 @@ describe "UNIXSocket#path" do https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/library/socket/unixsocket/path_spec.rb#L13 after :each do @client.close @server.close - rm_r @path + SocketSpecs.rm_socket @path end it "returns the path of the socket if it's a server" do Index: spec/rubyspec/library/socket/unixserver/for_fd_spec.rb =================================================================== --- spec/rubyspec/library/socket/unixserver/for_fd_spec.rb (revision 58717) +++ spec/rubyspec/library/socket/unixserver/for_fd_spec.rb (revision 58718) @@ -4,13 +4,13 @@ require File.expand_path('../../fixtures https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/library/socket/unixserver/for_fd_spec.rb#L4 platform_is_not :windows do describe "UNIXServer#for_fd" do before :each do - @unix_path = tmp("unix_socket") + @unix_path = SocketSpecs.socket_path @unix = UNIXServer.new(@unix_path) end after :each do @unix.close if @unix - rm_r @unix_path + SocketSpecs.rm_socket @unix_path end it "can calculate the path" do Index: spec/rubyspec/library/socket/unixsocket/send_io_spec.rb =================================================================== --- spec/rubyspec/library/socket/unixsocket/send_io_spec.rb (revision 58717) +++ spec/rubyspec/library/socket/unixsocket/send_io_spec.rb (revision 58718) @@ -20,7 +20,7 @@ describe "UNIXSocket#send_io" do https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/library/socket/unixsocket/send_io_spec.rb#L20 @file.close @client.close @server.close - rm_r @path + SocketSpecs.rm_socket @path end it "sends the fd for an IO object across the socket" do Index: spec/rubyspec/library/socket/unixsocket/partially_closable_spec.rb =================================================================== --- spec/rubyspec/library/socket/unixsocket/partially_closable_spec.rb (revision 58717) +++ spec/rubyspec/library/socket/unixsocket/partially_closable_spec.rb (revision 58718) @@ -7,7 +7,6 @@ platform_is_not :windows do https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/library/socket/unixsocket/partially_closable_spec.rb#L7 before :each do @path = SocketSpecs.socket_path - rm_r @path @server = UNIXServer.open(@path) @s1 = UNIXSocket.new(@path) @s2 = @server.accept @@ -17,7 +16,7 @@ platform_is_not :windows do https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/library/socket/unixsocket/partially_closable_spec.rb#L16 @server.close @s1.close @s2.close - rm_r @path + SocketSpecs.rm_socket @path end it_should_behave_like "partially closable sockets" Index: spec/rubyspec/library/socket/unixsocket/addr_spec.rb =================================================================== --- spec/rubyspec/library/socket/unixsocket/addr_spec.rb (revision 58717) +++ spec/rubyspec/library/socket/unixsocket/addr_spec.rb (revision 58718) @@ -6,8 +6,6 @@ describe "UNIXSocket#addr" do https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/library/socket/unixsocket/addr_spec.rb#L6 platform_is_not :windows do before :each do @path = SocketSpecs.socket_path - rm_r @path - @server = UNIXServer.open(@path) @client = UNIXSocket.open(@path) end @@ -15,7 +13,7 @@ describe "UNIXSocket#addr" do https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/library/socket/unixsocket/addr_spec.rb#L13 after :each do @client.close @server.close - rm_r @path + SocketSpecs.rm_socket @path end it "returns the address family of this socket in an array" do Index: spec/rubyspec/shared/time/strftime_for_date.rb =================================================================== --- spec/rubyspec/shared/time/strftime_for_date.rb (revision 58717) +++ spec/rubyspec/shared/time/strftime_for_date.rb (revision 58718) @@ -101,11 +101,7 @@ describe :strftime_date, shared: true do https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/shared/time/strftime_for_date.rb#L101 @d2000_4_6.strftime("%S").should == "00" end - it "should be able to show the number of seconds with leading zeroes" do - @d2000_4_6.strftime("%S").should == "00" - end - - it "should be able to show the number of seconds since the unix epoch" do + it "should be able to show the number of seconds since the unix epoch for a date" do @d2000_4_6.strftime("%s").should == "954979200" end @@ -171,7 +167,7 @@ describe :strftime_date, shared: true do https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/shared/time/strftime_for_date.rb#L167 @d2000_4_10.strftime("%u").should == "1" end - it "should be able to show the commercial week" do + it "should be able to show the commercial week with %V" do @d2000_4_9.strftime("%V").should == "14" @d2000_4_10.strftime("%V").should == "15" end @@ -218,12 +214,12 @@ describe :strftime_date, shared: true do https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/shared/time/strftime_for_date.rb#L214 @d2000_4_6.strftime("%F").should == @d2000_4_6.strftime('%Y-%m-%d') end - it "should be able to show HH:MM" do + it "should be able to show HH:MM for a date" do @d2000_4_6.strftime("%R").should == "00:00" @d2000_4_6.strftime("%R").should == @d2000_4_6.strftime('%H:%M') end - it "should be able to show HH:MM:SS AM/PM" do + it "should be able to show HH:MM:SS AM/PM for a date" do @d2000_4_6.strftime("%r").should == "12:00:00 AM" @d2000_4_6.strftime("%r").should == @d2000_4_6.strftime('%I:%M:%S %p') end Index: spec/rubyspec/language/heredoc_spec.rb =================================================================== --- spec/rubyspec/language/heredoc_spec.rb (revision 58717) +++ spec/rubyspec/language/heredoc_spec.rb (revision 58718) @@ -69,12 +69,12 @@ HERE https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/language/heredoc_spec.rb#L69 SquigglyHeredocSpecs.unquoted.should == "unquoted interpolated\n" end - it 'allows HEREDOC with <<"identifier", interpolated' do + it 'allows HEREDOC with <<~"identifier", interpolated' do require File.expand_path('../fixtures/squiggly_heredoc', __FILE__) SquigglyHeredocSpecs.doublequoted.should == "doublequoted interpolated\n" end - it "allows HEREDOC with <<'identifier', no interpolation" do + it "allows HEREDOC with <<~'identifier', no interpolation" do require File.expand_path('../fixtures/squiggly_heredoc', __FILE__) SquigglyHeredocSpecs.singlequoted.should == "singlequoted \#{\"interpolated\"}\n" end Index: spec/rubyspec/language/while_spec.rb =================================================================== --- spec/rubyspec/language/while_spec.rb (revision 58717) +++ spec/rubyspec/language/while_spec.rb (revision 58718) @@ -127,7 +127,7 @@ describe "The while expression" do https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/language/while_spec.rb#L127 a.should == [1, 2] end - it "stops running body if interrupted by break in a parenthesized attribute op-assign-or value" do + it "stops running body if interrupted by break with unless in a parenthesized attribute op-assign-or value" do a = mock("attribute assignment break") a.should_receive(:m).twice.and_return(nil) a.should_receive(:m=) @@ -142,7 +142,7 @@ describe "The while expression" do https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/language/while_spec.rb#L142 end.should be_nil end - it "stops running body if interrupted by break in a begin ... end attribute op-assign-or value" do + it "stops running body if interrupted by break with unless in a begin ... end attribute op-assign-or value" do a = mock("attribute assignment break") a.should_receive(:m).twice.and_return(nil) a.should_receive(:m=) Index: spec/rubyspec/language/variables_spec.rb =================================================================== --- spec/rubyspec/language/variables_spec.rb (revision 58717) +++ spec/rubyspec/language/variables_spec.rb (revision 58718) @@ -156,7 +156,7 @@ describe "Multiple assignment" do https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/language/variables_spec.rb#L156 [a, b, c].should == [1, [], 2] end - it "raises a TypeError if #to_ary does not return an Array" do + it "raises a TypeError if #to_ary does not return an Array with MLHS" do x = mock("multi-assign splat") x.should_receive(:to_ary).and_return(1) @@ -249,7 +249,7 @@ describe "Multiple assignment" do https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/language/variables_spec.rb#L249 [a, b].should == [1, 2] end - it "raises a TypeError if #to_ary does not return an Array" do + it "raises a TypeError if #to_ary does not return an Array on a single RHS" do y = mock("multi-assign method return value") y.should_receive(:to_ary).and_return(1) @@ -359,6 +359,10 @@ describe "Multiple assignment" do https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/language/variables_spec.rb#L359 (* = *a).should == [1] end + it "consumes values for a grouped anonymous splat" do + ((*) = *1).should == [1] + end + it "assigns a single LHS splat" do x = 1 (*a = *x).should == [1] @@ -445,15 +449,7 @@ describe "Multiple assignment" do https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/language/variables_spec.rb#L449 a.should == [x] end - it "calls #to_a to convert an Object RHS with a single LHS" do - x = mock("multi-assign splat") - x.should_receive(:to_a).and_return([1, 2]) - - a = *x - a.should == [1, 2] - end - - it "raises a TypeError if #to_a does not return an Array" do + it "raises a TypeError if #to_a does not return an Array with a single LHS" do x = mock("multi-assign splat") x.should_receive(:to_a).and_return(1) @@ -468,7 +464,7 @@ describe "Multiple assignment" do https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/language/variables_spec.rb#L464 [a, b, c].should == [1, 2, nil] end - it "raises a TypeError if #to_a does not return an Array" do + it "raises a TypeError if #to_a does not return an Array with a simple MLHS" do x = mock("multi-assign splat") x.should_receive(:to_a).and_return(1) @@ -491,7 +487,7 @@ describe "Multiple assignment" do https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/language/variables_spec.rb#L487 [a, b, c].should == [1, [], 2] end - it "raises a TypeError if #to_a does not return an Array" do + it "raises a TypeError if #to_a does not return an Array with MLHS" do x = mock("multi-assign splat") x.should_receive(:to_a).and_return(1) @@ -516,14 +512,6 @@ describe "Multiple assignment" do https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/language/variables_spec.rb#L512 [a, b, c, d, e, f, g].should == [1, [], nil, [], nil, [], nil] end - it "consumes values for an anonymous splat" do - (* = *1).should == [1] - end - - it "consumes values for a grouped anonymous splat" do - ((*) = *1).should == [1] - end - it "does not mutate a RHS Array" do x = [1, 2, 3, 4] a, *b, c, d = *x @@ -544,6 +532,10 @@ describe "Multiple assignment" do https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/language/v (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/