mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Revert "Special case Range#max for integer beginning and Float::Infinity end"
This reverts commit 05bf811c28
.
This commit is contained in:
parent
94430d009a
commit
e080a4cdee
Notes:
git
2020-09-02 02:53:11 +09:00
2 changed files with 0 additions and 15 deletions
9
range.c
9
range.c
|
@ -1255,15 +1255,6 @@ range_max(int argc, VALUE *argv, VALUE range)
|
||||||
return rb_funcall(e, '-', 1, INT2FIX(1));
|
return rb_funcall(e, '-', 1, INT2FIX(1));
|
||||||
}
|
}
|
||||||
if (RB_INTEGER_TYPE_P(b) && !RB_INTEGER_TYPE_P(e)) {
|
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);
|
e = rb_funcall(e, rb_intern("floor"), 0);
|
||||||
}
|
}
|
||||||
return e;
|
return e;
|
||||||
|
|
|
@ -131,9 +131,6 @@ class TestRange < Test::Unit::TestCase
|
||||||
assert_equal(2, (..2).max)
|
assert_equal(2, (..2).max)
|
||||||
assert_raise(TypeError) { (...2).max }
|
assert_raise(TypeError) { (...2).max }
|
||||||
assert_raise(TypeError) { (...2.0).max }
|
assert_raise(TypeError) { (...2.0).max }
|
||||||
|
|
||||||
assert_equal(Float::INFINITY, (1..Float::INFINITY).max)
|
|
||||||
assert_nil((1..-Float::INFINITY).max)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_minmax
|
def test_minmax
|
||||||
|
@ -160,9 +157,6 @@ class TestRange < Test::Unit::TestCase
|
||||||
|
|
||||||
assert_equal(['a', 'c'], ('a'..'c').minmax)
|
assert_equal(['a', 'c'], ('a'..'c').minmax)
|
||||||
assert_equal(['a', 'b'], ('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
|
end
|
||||||
|
|
||||||
def test_initialize_twice
|
def test_initialize_twice
|
||||||
|
|
Loading…
Add table
Reference in a new issue