ruby-changes:60639
From: Nobuyoshi <ko1@a...>
Date: Fri, 3 Apr 2020 10:37:00 +0900 (JST)
Subject: [ruby-changes:60639] 18f7d3c9a6 (master): Refined "Drop support for ruby 2.4 from ruby/spec"
https://git.ruby-lang.org/ruby.git/commit/?id=18f7d3c9a6 From 18f7d3c9a647f31f11e182d900b88edf5e34ea4b Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Fri, 3 Apr 2020 09:44:40 +0900 Subject: Refined "Drop support for ruby 2.4 from ruby/spec" By using spec/mspec/tool/remove_old_guards.rb. diff --git a/spec/ruby/command_line/dash_l_spec.rb b/spec/ruby/command_line/dash_l_spec.rb index 65d6592..5c1d3cf 100644 --- a/spec/ruby/command_line/dash_l_spec.rb +++ b/spec/ruby/command_line/dash_l_spec.rb @@ -14,7 +14,7 @@ describe "The -l command line option" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/command_line/dash_l_spec.rb#L14 it "chomps last line based on $/" do ruby_exe('BEGIN { $/ = "ones\n" }; puts $_', options: "-W0 -n -l", escape: true, args: " < #{@names}").should == - "alice j\nbob field\njames grey\n" + "alice j\nbob field\njames grey\n" end it "sets $\\ to the value of $/" do diff --git a/spec/ruby/core/dir/shared/glob.rb b/spec/ruby/core/dir/shared/glob.rb index 0fcfcc4..fcaa0d8 100644 --- a/spec/ruby/core/dir/shared/glob.rb +++ b/spec/ruby/core/dir/shared/glob.rb @@ -296,10 +296,10 @@ describe :dir_glob, shared: true do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/dir/shared/glob.rb#L296 @mock_dir = File.expand_path tmp('dir_glob_mock') %w[ - a/b/x - a/b/c/y - a/b/c/d/z - ].each do |path| + a/b/x + a/b/c/y + a/b/c/d/z + ].each do |path| file = File.join @mock_dir, path mkdir_p File.dirname(file) touch file diff --git a/spec/ruby/core/file/utime_spec.rb b/spec/ruby/core/file/utime_spec.rb index 9c198af..d703681 100644 --- a/spec/ruby/core/file/utime_spec.rb +++ b/spec/ruby/core/file/utime_spec.rb @@ -3,7 +3,7 @@ require_relative '../../spec_helper' https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/file/utime_spec.rb#L3 describe "File.utime" do before :all do - @time_is_float = /mswin|mingw/ =~ RUBY_PLATFORM && RUBY_VERSION >= '2.5' + @time_is_float = /mswin|mingw/ =~ RUBY_PLATFORM end before :each do diff --git a/spec/ruby/core/integer/pow_spec.rb b/spec/ruby/core/integer/pow_spec.rb index f3fb1da..d7561ba 100644 --- a/spec/ruby/core/integer/pow_spec.rb +++ b/spec/ruby/core/integer/pow_spec.rb @@ -23,8 +23,8 @@ describe "Integer#pow" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/integer/pow_spec.rb#L23 end it "handles sign like #divmod does" do - 2.pow(5, 12).should == 8 - 2.pow(5, -12).should == -4 + 2.pow(5, 12).should == 8 + 2.pow(5, -12).should == -4 -2.pow(5, 12).should == 4 -2.pow(5, -12).should == -8 end diff --git a/spec/ruby/core/integer/shared/arithmetic_coerce.rb b/spec/ruby/core/integer/shared/arithmetic_coerce.rb index 1260192..4c0cbcb 100644 --- a/spec/ruby/core/integer/shared/arithmetic_coerce.rb +++ b/spec/ruby/core/integer/shared/arithmetic_coerce.rb @@ -1,5 +1,25 @@ https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/integer/shared/arithmetic_coerce.rb#L1 require_relative '../fixtures/classes' +describe :integer_arithmetic_coerce_rescue, shared: true do + it "rescues exception (StandardError and subclasses) raised in other#coerce and raises TypeError" do + b = mock("numeric with failed #coerce") + b.should_receive(:coerce).and_raise(IntegerSpecs::CoerceError) + + # e.g. 1 + b + -> { 1.send(@method, b) }.should raise_error(TypeError, /MockObject can't be coerced into Integer/) + end + + it "does not rescue Exception and StandardError siblings raised in other#coerce" do + [Exception, NoMemoryError].each do |exception| + b = mock("numeric with failed #coerce") + b.should_receive(:coerce).and_raise(exception) + + # e.g. 1 + b + -> { 1.send(@method, b) }.should raise_error(exception) + end + end +end + describe :integer_arithmetic_coerce_not_rescue, shared: true do it "does not rescue exception raised in other#coerce" do b = mock("numeric with failed #coerce") diff --git a/spec/ruby/language/ensure_spec.rb b/spec/ruby/language/ensure_spec.rb index da2389e..e94c523 100644 --- a/spec/ruby/language/ensure_spec.rb +++ b/spec/ruby/language/ensure_spec.rb @@ -259,13 +259,13 @@ describe "An ensure block inside 'do end' block" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/language/ensure_spec.rb#L259 it "is executed when an exception is raised in it's corresponding begin block" do -> { eval(<<-ruby).call - lambda do - ScratchPad << :begin - raise EnsureSpec::Error - ensure - ScratchPad << :ensure - end - ruby + lambda do + ScratchPad << :begin + raise EnsureSpec::Error + ensure + ScratchPad << :ensure + end + ruby }.should raise_error(EnsureSpec::Error) ScratchPad.recorded.should == [:begin, :ensure] @@ -273,15 +273,15 @@ describe "An ensure block inside 'do end' block" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/language/ensure_spec.rb#L273 it "is executed when an exception is raised and rescued in it's corresponding begin block" do eval(<<-ruby).call - lambda do - ScratchPad << :begin - raise "An exception occurred!" - rescue - ScratchPad << :rescue - ensure - ScratchPad << :ensure - end - ruby + lambda do + ScratchPad << :begin + raise "An exception occurred!" + rescue + ScratchPad << :rescue + ensure + ScratchPad << :ensure + end + ruby ScratchPad.recorded.should == [:begin, :rescue, :ensure] end @@ -289,42 +289,42 @@ describe "An ensure block inside 'do end' block" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/language/ensure_spec.rb#L289 it "is executed even when a symbol is thrown in it's corresponding begin block" do catch(:symbol) do eval(<<-ruby).call - lambda do - ScratchPad << :begin - throw(:symbol) - rescue - ScratchPad << :rescue - ensure - ScratchPad << :ensure - end - ruby - end - - ScratchPad.recorded.should == [:begin, :ensure] - end - - it "is executed when nothing is raised or thrown in it's corresponding begin block" do - eval(<<-ruby).call lambda do ScratchPad << :begin + throw(:symbol) rescue ScratchPad << :rescue ensure ScratchPad << :ensure end ruby + end + + ScratchPad.recorded.should == [:begin, :ensure] + end + + it "is executed when nothing is raised or thrown in it's corresponding begin block" do + eval(<<-ruby).call + lambda do + ScratchPad << :begin + rescue + ScratchPad << :rescue + ensure + ScratchPad << :ensure + end + ruby ScratchPad.recorded.should == [:begin, :ensure] end it "has no return value" do result = eval(<<-ruby).call - lambda do - :begin - ensure - :ensure - end - ruby + lambda do + :begin + ensure + :ensure + end + ruby result.should == :begin end diff --git a/spec/ruby/language/rescue_spec.rb b/spec/ruby/language/rescue_spec.rb index aa52932..7fa674d 100644 --- a/spec/ruby/language/rescue_spec.rb +++ b/spec/ruby/language/rescue_spec.rb @@ -437,12 +437,12 @@ describe "The rescue keyword" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/language/rescue_spec.rb#L437 it "allows rescue in 'do end' block" do lambda = eval <<-ruby - lambda do - raise SpecificExampleException - rescue SpecificExampleException - ScratchPad << :caught - end.call - ruby + lambda do + raise SpecificExampleException + rescue SpecificExampleException + ScratchPad << :caught + end.call + ruby ScratchPad.recorded.should == [:caught] end diff --git a/spec/ruby/language/return_spec.rb b/spec/ruby/language/return_spec.rb index 6b428c3..d850683 100644 --- a/spec/ruby/language/return_spec.rb +++ b/spec/ruby/language/return_spec.rb @@ -262,11 +262,11 @@ describe "The return keyword" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/language/return_spec.rb#L262 it "stops file execution" do ruby_exe(<<-END_OF_CODE).should == "before return\n" - puts "before return" - return + puts "before return" + return - puts "after return" - END_OF_CODE + puts "after return" + END_OF_CODE $?.exitstatus.should == 0 end @@ -274,13 +274,13 @@ describe "The return keyword" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/language/return_spec.rb#L274 describe "within if" do it "is allowed" do File.write(@filename, <<-END_OF_CODE) - ScratchPad << "before if" - if true - return - end + ScratchPad << "before if" + if true + return + end - ScratchPad << "after if" - END_OF_CODE + ScratchPad << "after if" + END_OF_CODE load @filename ScratchPad.recorded.should == ["before if"] @@ -290,13 +290,13 @@ describe "The return keyword" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/language/return_spec.rb#L290 describe "within while loop" do it "is allowed" do File.write(@filename, <<-END_OF_CODE) - ScratchPad << "before while" - while true - return - end + ScratchPad << "before while" + while true + return + end - ScratchPad << "after while" - END_OF_CODE + ScratchPad << "after while" + END_OF_CODE load @filename ScratchPad.recorded.should == ["before while"] (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/