ruby-changes:47476
From: eregon <ko1@a...>
Date: Tue, 15 Aug 2017 06:03:39 +0900 (JST)
Subject: [ruby-changes:47476] eregon:r59432 (trunk): Update to ruby/spec@c3e6b90
eregon 2017-07-27 21:10:41 +0900 (Thu, 27 Jul 2017) New Revision: 59432 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=59432 Log: Update to ruby/spec@c3e6b90 Added files: trunk/spec/rubyspec/library/bigdecimal/to_r_spec.rb Modified files: trunk/spec/rubyspec/Gemfile trunk/spec/rubyspec/core/array/pack/j_spec.rb trunk/spec/rubyspec/core/array/pack/l_spec.rb trunk/spec/rubyspec/core/io/close_on_exec_spec.rb trunk/spec/rubyspec/core/numeric/step_spec.rb trunk/spec/rubyspec/core/process/setrlimit_spec.rb trunk/spec/rubyspec/core/string/shared/slice.rb trunk/spec/rubyspec/core/string/unpack/l_spec.rb trunk/spec/rubyspec/core/thread/fixtures/classes.rb trunk/spec/rubyspec/core/thread/inspect_spec.rb trunk/spec/rubyspec/core/thread/status_spec.rb trunk/spec/rubyspec/core/thread/stop_spec.rb trunk/spec/rubyspec/language/break_spec.rb trunk/spec/rubyspec/language/fixtures/break.rb trunk/spec/rubyspec/language/fixtures/defined.rb trunk/spec/rubyspec/library/stringscanner/shared/peek.rb trunk/spec/rubyspec/optional/capi/ext/io_spec.c trunk/spec/rubyspec/optional/capi/globals_spec.rb trunk/spec/rubyspec/optional/capi/object_spec.rb trunk/spec/rubyspec/optional/capi/thread_spec.rb Index: spec/rubyspec/language/break_spec.rb =================================================================== --- spec/rubyspec/language/break_spec.rb (revision 59431) +++ spec/rubyspec/language/break_spec.rb (revision 59432) @@ -40,12 +40,12 @@ describe "The break statement in a captu https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/language/break_spec.rb#L40 it "raises a LocalJumpError when invoking the block from a method" do lambda { @program.break_in_nested_method }.should raise_error(LocalJumpError) - ScratchPad.recorded.should == [:a, :xa, :c, :aa, :b] + ScratchPad.recorded.should == [:a, :xa, :cc, :aa, :b] end it "raises a LocalJumpError when yielding to the block" do lambda { @program.break_in_yielding_method }.should raise_error(LocalJumpError) - ScratchPad.recorded.should == [:a, :xa, :c, :aa, :b] + ScratchPad.recorded.should == [:a, :xa, :cc, :aa, :b] end end @@ -60,6 +60,20 @@ describe "The break statement in a captu https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/language/break_spec.rb#L60 ScratchPad.recorded.should == [:a, :za, :xa, :zd, :aa, :zb] end end + + describe "from another thread" do + it "raises a LocalJumpError when getting the value from another thread" do + ScratchPad << :a + thread_with_break = Thread.new do + ScratchPad << :b + break :break + ScratchPad << :c + end + + lambda { thread_with_break.value }.should raise_error(LocalJumpError) + ScratchPad.recorded.should == [:a, :b] + end + end end describe "The break statement in a lambda" do Index: spec/rubyspec/language/fixtures/break.rb =================================================================== --- spec/rubyspec/language/fixtures/break.rb (revision 59431) +++ spec/rubyspec/language/fixtures/break.rb (revision 59432) @@ -89,7 +89,7 @@ module BreakSpecs https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/language/fixtures/break.rb#L89 break :break note :c } - note :c + note :cc note call_method(b) note :d end @@ -101,7 +101,7 @@ module BreakSpecs https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/language/fixtures/break.rb#L101 break :break note :c } - note :c + note :cc note yielding(&b) note :d end Index: spec/rubyspec/language/fixtures/defined.rb =================================================================== --- spec/rubyspec/language/fixtures/defined.rb (revision 59431) +++ spec/rubyspec/language/fixtures/defined.rb (revision 59432) @@ -83,7 +83,9 @@ module DefinedSpecs https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/language/fixtures/defined.rb#L83 end def global_variable_read - value = $defined_specs_global_variable_read + suppress_warning do + value = $defined_specs_global_variable_read + end defined? $defined_specs_global_variable_read end Index: spec/rubyspec/optional/capi/globals_spec.rb =================================================================== --- spec/rubyspec/optional/capi/globals_spec.rb (revision 59431) +++ spec/rubyspec/optional/capi/globals_spec.rb (revision 59432) @@ -188,7 +188,7 @@ describe "CApiGlobalSpecs" do https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/optional/capi/globals_spec.rb#L188 running = true end - Thread.pass until running + Thread.pass while thr.status and !running $_.should be_nil thr.join @@ -215,7 +215,7 @@ describe "CApiGlobalSpecs" do https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/optional/capi/globals_spec.rb#L215 running = true end - Thread.pass until running + Thread.pass while thr.status and !running $_.should be_nil thr.join Index: spec/rubyspec/optional/capi/thread_spec.rb =================================================================== --- spec/rubyspec/optional/capi/thread_spec.rb (revision 59431) +++ spec/rubyspec/optional/capi/thread_spec.rb (revision 59432) @@ -107,6 +107,10 @@ describe "C-API Thread function" do https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/optional/capi/thread_spec.rb#L107 # Wait until it's blocking... Thread.pass while thr.status and thr.status != "sleep" + # The thread status is set to sleep by rb_thread_call_without_gvl(), + # but the thread might not be in the blocking read(2) yet, so wait a bit. + sleep 0.1 + # Wake it up, causing the unblock function to be run. thr.wakeup Index: spec/rubyspec/optional/capi/ext/io_spec.c =================================================================== --- spec/rubyspec/optional/capi/ext/io_spec.c (revision 59431) +++ spec/rubyspec/optional/capi/ext/io_spec.c (revision 59432) @@ -1,6 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/optional/capi/ext/io_spec.c#L1 #include "ruby.h" #include "rubyspec.h" #include "ruby/io.h" +#include <errno.h> #include <fcntl.h> #ifdef HAVE_UNISTD_H #include <unistd.h> @@ -133,46 +134,46 @@ VALUE io_spec_rb_io_taint_check(VALUE se https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/optional/capi/ext/io_spec.c#L134 } #endif -typedef int wait_bool; -#define wait_bool_to_ruby_bool(x) (x ? Qtrue : Qfalse) - #ifdef HAVE_RB_IO_WAIT_READABLE #define RB_IO_WAIT_READABLE_BUF 13 VALUE io_spec_rb_io_wait_readable(VALUE self, VALUE io, VALUE read_p) { int fd = io_spec_get_fd(io); char buf[RB_IO_WAIT_READABLE_BUF]; - wait_bool ret; + int ret, r, saved_errno; if (set_non_blocking(fd) == -1) rb_sys_fail("set_non_blocking failed"); if(RTEST(read_p)) { - if(read(fd, buf, RB_IO_WAIT_READABLE_BUF) != -1) { + if (read(fd, buf, RB_IO_WAIT_READABLE_BUF) != -1) { return Qnil; } + saved_errno = errno; rb_ivar_set(self, rb_intern("@write_data"), Qtrue); + errno = saved_errno; } ret = rb_io_wait_readable(fd); if(RTEST(read_p)) { - if(read(fd, buf, RB_IO_WAIT_READABLE_BUF) != 13) { - return Qnil; + r = read(fd, buf, RB_IO_WAIT_READABLE_BUF); + if (r != RB_IO_WAIT_READABLE_BUF) { + perror("read"); + return INT2FIX(r); } rb_ivar_set(self, rb_intern("@read_data"), rb_str_new(buf, RB_IO_WAIT_READABLE_BUF)); } - return wait_bool_to_ruby_bool(ret); + return ret ? Qtrue : Qfalse; } #endif #ifdef HAVE_RB_IO_WAIT_WRITABLE VALUE io_spec_rb_io_wait_writable(VALUE self, VALUE io) { - wait_bool ret; - ret = rb_io_wait_writable(io_spec_get_fd(io)); - return wait_bool_to_ruby_bool(ret); + int ret = rb_io_wait_writable(io_spec_get_fd(io)); + return ret ? Qtrue : Qfalse; } #endif Index: spec/rubyspec/optional/capi/object_spec.rb =================================================================== --- spec/rubyspec/optional/capi/object_spec.rb (revision 59431) +++ spec/rubyspec/optional/capi/object_spec.rb (revision 59432) @@ -175,6 +175,7 @@ describe "CApiObject" do https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/optional/capi/object_spec.rb#L175 describe "rb_require" do before :each do @saved_loaded_features = $LOADED_FEATURES.dup + $foo = nil end after :each do @@ -183,7 +184,6 @@ describe "CApiObject" do https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/optional/capi/object_spec.rb#L184 end it "requires a ruby file" do - $foo.should == nil $:.unshift File.dirname(__FILE__) @o.rb_require() $foo.should == 7 Index: spec/rubyspec/core/numeric/step_spec.rb =================================================================== --- spec/rubyspec/core/numeric/step_spec.rb (revision 59431) +++ spec/rubyspec/core/numeric/step_spec.rb (revision 59432) @@ -65,6 +65,10 @@ describe "Numeric#step" do https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/core/numeric/step_spec.rb#L65 describe "when no block is given" do describe "returned Enumerator" do describe "size" do + it "should return infinity_value when limit is nil" do + 1.step(by: 42).size.should == infinity_value + end + it "should return infinity_value when step is 0" do 1.step(to: 5, by: 0).size.should == infinity_value end @@ -73,13 +77,21 @@ describe "Numeric#step" do https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/core/numeric/step_spec.rb#L77 1.step(to: 2, by: 0.0).size.should == infinity_value end - it "should return infinity_value when the limit is Float::INFINITY" do + it "should return infinity_value when ascending towards a limit of Float::INFINITY" do 1.step(to: Float::INFINITY, by: 42).size.should == infinity_value end + it "should return infinity_value when decending towards a limit of -Float::INFINITY" do + 1.step(to: -Float::INFINITY, by: -42).size.should == infinity_value + end + it "should return 1 when the both limit and step are Float::INFINITY" do 1.step(to: Float::INFINITY, by: Float::INFINITY).size.should == 1 end + + it "should return 1 when the both limit and step are -Float::INFINITY" do + 1.step(to: -Float::INFINITY, by: -Float::INFINITY).size.should == 1 + end end end end Index: spec/rubyspec/core/thread/status_spec.rb =================================================================== --- spec/rubyspec/core/thread/status_spec.rb (revision 59431) +++ spec/rubyspec/core/thread/status_spec.rb (revision 59432) @@ -34,9 +34,11 @@ describe "Thread#status" do https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/core/thread/status_spec.rb#L34 ThreadSpecs.status_of_dying_sleeping_thread.status.should == 'sleep' end - quarantine! do it "reports aborting on a killed thread" do - ThreadSpecs.status_of_aborting_thread.status.should == 'aborting' + ThreadSpecs.status_of_dying_running_thread.status.should == 'aborting' end + + it "reports aborting on a killed thread after sleep" do + ThreadSpecs.status_of_dying_thread_after_sleep.status.should == 'aborting' end end Index: spec/rubyspec/core/thread/stop_spec.rb =================================================================== --- spec/rubyspec/core/thread/stop_spec.rb (revision 59431) +++ spec/rubyspec/core/thread/stop_spec.rb (revision 59432) @@ -48,9 +48,7 @@ describe "Thread#stop?" do https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/core/thread/stop_spec.rb#L48 ThreadSpecs.status_of_dying_sleeping_thread.stop?.should == true end - quarantine! do - it "reports aborting on a killed thread" do - ThreadSpecs.status_of_aborting_thread.stop?.should == false - end + it "describes a dying thread after sleep" do + ThreadSpecs.status_of_dying_thread_after_sleep.stop?.should == false end end Index: spec/rubyspec/core/thread/inspect_spec.rb =================================================================== --- spec/rubyspec/core/thread/inspect_spec.rb (revision 59431) +++ spec/rubyspec/core/thread/inspect_spec.rb (revision 59432) @@ -31,12 +31,14 @@ describe "Thread#inspect" do https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/core/thread/inspect_spec.rb#L31 end it "describes a dying sleeping thread" do - ThreadSpecs.status_of_dying_sleeping_thread.status.should include('sleep') + ThreadSpecs.status_of_dying_sleeping_thread.inspect.should include('sleep') end - quarantine! do it "reports aborting on a killed thread" do - ThreadSpecs.status_of_aborting_thread.inspect.should include('aborting') + ThreadSpecs.status_of_dying_running_thread.inspect.should include('aborting') end + + it "reports aborting on a killed thread after sleep" do + ThreadSpecs.status_of_dying_thread_after_sleep.inspect.should include('aborting') end end Index: spec/rubyspec/core/thread/fixtures/classes.rb =================================================================== --- spec/rubyspec/core/thread/fixtures/classes.rb (revision 59431) +++ spec/rubyspec/core/thread/fixtures/classes.rb (revision 59432) @@ -111,9 +111,6 @@ module ThreadSpecs https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/core/thread/fixtures/classes.rb#L111 status end - def self.status_of_aborting_thread - end - def self.status_of_killed_thread t = Thread.new { sleep } Thread.pass while t.status and t.status != 'sleep' @@ -146,6 +143,19 @@ module ThreadSpecs https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/core/thread/fixtures/classes.rb#L143 t.join status end + + def self.status_of_dying_thread_after_sleep + status = nil + t = dying_thread_ensures { + Thread.stop + status = Status.new(Thread.current) + } + Thread.pass while t.status and t.status != 'sleep' + t.wakeup + Thread.pass while t.status and t.status == 'sleep' + t.join + status + end def self.dying_thread_ensures(kill_method_name=:kill) Thread.new do Index: spec/rubyspec/core/string/unpack/l_spec.rb =================================================================== --- spec/rubyspec/core/string/unpack/l_spec.rb (revision 59431) +++ spec/rubyspec/core/string/unpack/l_spec.rb (revision 59432) @@ -14,7 +14,7 @@ describe "String#unpack with format 'L'" https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/core/string/unpack/l_spec.rb#L14 it_behaves_like :string_unpack_32bit_be_unsigned, 'L>' end - platform_is wordsize: 32 do + guard -> { platform_is wordsize: 32 or platform_is :mingw32 } do describe "with modifier '<' and '_'" do it_behaves_like :string_unpack_32bit_le, 'L<_' it_behaves_like :string_unpack_32bit_le, 'L_<' @@ -44,65 +44,33 @@ describe "String#unpack with format 'L'" https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/core/string/unpack/l_spec.rb#L44 end end - platform_is wordsize: 64 do - platform_is_not :mingw32 do - describe "with modifier '<' and '_'" do - it_behaves_like :string_unpack_64bit_le, 'L<_' - it_behaves_like :string_unpack_64bit_le, 'L_<' - it_behaves_like :string_unpack_64bit_le_unsigned, 'L<_' - it_behaves_like :string_unpack_64bit_le_unsigned, 'L_<' - end - - describe "with modifier '<' and '!'" do - it_behaves_like :string_unpack_64bit_le, 'L<!' - it_behaves_like :string_unpack_64bit_le, 'L!<' - it_behaves_like :string_unpack_64bit_le_unsigned, 'L<!' - it_behaves_like :string_unpack_64bit_le_unsigned, 'L!<' - end - - describe "with modifier '>' and '_'" do - it_behaves_like :string_unpack_64bit_be, 'L>_' - it_behaves_like :string_unpack_64bit_be, 'L_>' - it_behaves_like :string_unpack_64bit_be_unsigned, 'L>_' - it_behaves_like :string_unpack_64bit_be_unsigned, 'L_>' - end - - describe "with modifier '>' and '!'" do - it_behaves_like :string_unpack_64bit_be, 'L>!' - it_behaves_like :string_unpack_64bit_be, 'L!>' - it_behaves_like :string_unpack_64bit_be_unsigned, 'L>!' - it_behaves_like :string_unpack_64bit_be_unsigned, 'L!>' - end - end - - platform_is :mingw32 do - describe "with modifier '<' and '_'" do - it_behaves_like :string_unpack_32bit_le, 'L<_' - it_behaves_like :string_unpack_32bit_le, 'L_<' - it_behaves_like :string_unpack_32bit_le_unsigned, 'L<_' - it_behaves_like :string_unpack_32bit_le_unsigned, 'L_<' - end - - describe "with modifier '<' and '!'" do - it_behaves_like :string_unpack_32bit_le, 'L<!' - it_behaves_like :string_unpack_32bit_le, 'L!<' - it_behaves_like :string_unpack_32bit_le_unsigned, 'L<!' - it_behaves_like :string_unpack_32bit_le_unsigned, 'L!<' - end - - describe "with modifier '>' and '_'" do - it_behaves_like :string_unpack_32bit_be, 'L>_' - it_behaves_like :string_unpack_32bit_be, 'L_>' - it_behaves_like :string_unpack_32bit_be_unsigned, 'L>_' - it_behaves_like :string_unpack_32bit_be_unsigned, 'L_>' - end - - describe "with modifier '>' and '!'" do - it_behaves_like :string_unpack_32bit_be, 'L>!' - it_behaves_like :string_unpack_32bit_be, 'L!>' - it_behaves_like :string_unpack_32bit_be_unsigned, 'L>!' - it_behaves_like :string_unpack_32bit_be_unsigned, 'L!>' - end + guard -> { platform_is wordsize: 64 and platform_is_not :mingw32 } do + describe "with modifier '<' and '_'" do + it_behaves_like :string_unpack_64bit_le, 'L<_' + it_behaves_like :string_unpack_64bit_le, 'L_<' + it_behaves_like :string_unpack_64bit_le_unsigned, 'L<_' + it_behaves_like :string_unpack_64bit_le_unsigned, 'L_<' + end + + describe "with modifier '<' and '!'" do + it_behaves_like :string_unpack_64bit_le, 'L<!' + it_behaves_like :string_unpack_64bit_le, 'L!<' + it_behaves_like :string_unpack_64bit_le_unsigned, 'L<!' + it_behaves_like :string_unpack_64bit_le_unsigned, 'L!<' + end + + describe "with modifier '>' and '_'" do + it_behaves_like :string_unpack_64bit_be, 'L>_' + it_behaves_like :string_unpack_64bit_be, 'L_>' + it_behaves_like :string_unpack_64bit_be_unsigned, 'L>_' + it_behaves_like :string_unpack_64bit_be_unsigned, 'L_>' + end + + describe "with modifier '>' and '!'" do + it_behaves_like :string_unpack_64bit_be, 'L>!' + it_behaves_like :string_unpack_64bit_be, 'L!>' + it_behaves_like :string_unpack_64bit_be_unsigned, 'L>!' + it_behaves_like :string_unpack_64bit_be_unsigned, 'L!>' end end end @@ -118,7 +86,7 @@ describe "String#unpack with format 'l'" https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/core/string/unpack/l_spec.rb#L86 it_behaves_like :string_unpack_32bit_be_signed, 'l>' end - platform_is wordsize: 32 do + guard -> { platform_is wordsize: 32 or platform_is :mingw32 } do describe "with modifier '<' and '_'" do it_behaves_like :string_unpack_32bit_le, 'l<_' it_behaves_like :string_unpack_32bit_le, 'l_<' @@ -148,65 +116,33 @@ describe "String#unpack with format 'l'" https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/core/string/unpack/l_spec.rb#L116 end end - platform_is wordsize: 64 do - platform_is_not :mingw32 do - describe "with modifier '<' and '_'" do - it_behaves_like :string_unpack_64bit_le, 'l<_' - it_behaves_like :string_unpack_64bit_le, 'l_<' - it_behaves_like :string_unpack_64bit_le_signed, 'l<_' - it_behaves_like :string_unpack_64bit_le_signed, 'l_<' - end - - describe "with modifier '<' and '!'" do - it_behaves_like :string_unpack_64bit_le, 'l<!' - it_behaves_like :string_unpack_64bit_le, 'l!<' - it_behaves_like :string_unpack_64bit_le_signed, 'l<!' - it_behaves_like :string_unpack_64bit_le_signed, 'l!<' - end - - describe "with modifier '>' and '_'" do - it_behaves_like :string_unpack_64bit_be, 'l>_' - it_behaves_like :string_unpack_64bit_be, 'l_>' - it_behaves_like :string_unpack_64bit_be_signed, 'l>_' - it_behaves_like :string_unpack_64bit_be_signed, 'l_>' - end - - describe "with modifier '>' and '!'" do - it_behaves_like :string_unpack_64bit_be, 'l>!' - it_behaves_like :string_unpack_64bit_be, 'l!>' - it_behaves_like :string_unpack_64bit_be_signed, 'l>!' - it_behaves_like :string_unpack_64bit_be_signed, 'l!>' - end - end - - platform_is :mingw32 do - describe "with modifier '<' and '_'" do - it_behaves_like :string_unpack_32bit_le, 'l<_' - it_behaves_like :string_unpack_32bit_le, 'l_<' - it_behaves_like :string_unpack_32bit_le_signed, 'l<_' - it_behaves_like :string_unpack_32bit_le_signed, 'l_<' - end - - describe "with modifier '<' and '!'" do - it_behaves_l (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/