[前][次][番号順一覧][スレッド一覧]

ruby-changes:62797

From: Jeremy <ko1@a...>
Date: Wed, 2 Sep 2020 02:53:02 +0900 (JST)
Subject: [ruby-changes:62797] e080a4cdee (master): Revert "Special case Range#max for integer beginning and Float::Infinity end"

https://git.ruby-lang.org/ruby.git/commit/?id=e080a4cdee

From e080a4cdeeb55dddb6247ffd2563d2dc8b84c919 Mon Sep 17 00:00:00 2001
From: Jeremy Evans <code@j...>
Date: Tue, 1 Sep 2020 09:18:44 -0700
Subject: Revert "Special case Range#max for integer beginning and
 Float::Infinity end"

This reverts commit 05bf811c2839628aaef3d565daedb28be80d47ef.

diff --git a/range.c b/range.c
index 6d507ea..124d9fa 100644
--- a/range.c
+++ b/range.c
@@ -1255,15 +1255,6 @@ range_max(int argc, VALUE *argv, VALUE range) https://github.com/ruby/ruby/blob/trunk/range.c#L1255
             return rb_funcall(e, '-', 1, INT2FIX(1));
         }
         if (RB_INTEGER_TYPE_P(b) && !RB_INTEGER_TYPE_P(e)) {
-            if (RB_TYPE_P(e, T_FLOAT)) {
-                VALUE inf = rb_funcall(e, rb_intern("infinite?"), 0);
-                if (inf != Qnil) {
-                  /* For backwards compatibility, return end if the end
-                   * is Float::Infinity and the beginning is integer.
-                     If end is -Float::Infinity, return nil. */
-                  return(inf == INT2FIX(1) ? e : Qnil);
-                }
-            }
             e = rb_funcall(e, rb_intern("floor"), 0);
         }
         return e;
diff --git a/test/ruby/test_range.rb b/test/ruby/test_range.rb
index 0dc6644..0b3f6c6 100644
--- a/test/ruby/test_range.rb
+++ b/test/ruby/test_range.rb
@@ -131,9 +131,6 @@ class TestRange < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_range.rb#L131
     assert_equal(2, (..2).max)
     assert_raise(TypeError) { (...2).max }
     assert_raise(TypeError) { (...2.0).max }
-
-    assert_equal(Float::INFINITY, (1..Float::INFINITY).max)
-    assert_nil((1..-Float::INFINITY).max)
   end
 
   def test_minmax
@@ -160,9 +157,6 @@ class TestRange < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_range.rb#L157
 
     assert_equal(['a', 'c'], ('a'..'c').minmax)
     assert_equal(['a', 'b'], ('a'...'c').minmax)
-
-    assert_equal([1, Float::INFINITY], (1..Float::INFINITY).minmax)
-    assert_equal([nil, nil], (1..-Float::INFINITY).minmax)
   end
 
   def test_initialize_twice
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]