From 967eb01cf141dc5d3a9cbaecec57ce7ba492b438 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Mittag?= Date: Sun, 3 Oct 2021 14:17:44 +0200 Subject: [PATCH 1/1] Remove unnecessary checks in `Range#each` [Bug #18237] In commit:7817a438eb1803e7b3358f43bd1f38479badfbdc, the implementation of `Time#succ`, which had been deprecated for 10 years, was finally removed. During that time, there was an explicit `instance_of?` check in source:range.c#L350 with a comment that the check should be removed once `Time#succ` is removed. Since `Time#succ` is now gone, the corresponding test should be guarded by a version constraint. --- core/range/each_spec.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/core/range/each_spec.rb b/core/range/each_spec.rb index bd4bbb82e..2f7edc5c1 100644 --- a/core/range/each_spec.rb +++ b/core/range/each_spec.rb @@ -84,9 +84,11 @@ describe "Range#each" do enum.to_a.should == [1, 2, 3] end - it "raises a TypeError if the first element is a Time object" do - t = Time.now - -> { (t..t+1).each { |i| i } }.should raise_error(TypeError) + ruby_version_is ""..."3.1" do + it "raises a TypeError if the first element is a Time object" do + t = Time.now + -> { (t..t+1).each { |i| i } }.should raise_error(TypeError) + end end it "passes each Symbol element by using #succ" do -- 2.30.1 (Apple Git-130)