Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

* range.c (range_max): fix behavior with excluded end value.

	  [Bug #4591]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32482 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information...
commit d22e08f9375dbc0d0a962751d1c57f17b22f01b6 1 parent b1d647c
@tarui tarui authored
Showing with 10 additions and 0 deletions.
  1. +5 −0 ChangeLog
  2. +3 −0  range.c
  3. +2 −0  test/ruby/test_range.rb
View
5 ChangeLog
@@ -1,3 +1,8 @@
+Sun Jul 10 09:46:14 2011 Masaya Tarui <tarui@ruby-lnag.org>
+
+ * range.c (range_max): fix behavior with excluded end value.
+ [Bug #4591]
+
Sun Jul 10 09:13:18 2011 Eric Hodel <drbrain@segment7.net>
* NEWS: Fix RubyGems version. [Ruby 1.9 - Bug #5004]
View
3  range.c
@@ -665,6 +665,9 @@ range_max(VALUE range)
rb_raise(rb_eTypeError, "cannot exclude non Integer end value");
}
if (c == 0) return Qnil;
+ if (!FIXNUM_P(b) && !rb_obj_is_kind_of(b,rb_cInteger)) {
+ rb_raise(rb_eTypeError, "cannot exclude end value with non Integer begin value");
+ }
if (FIXNUM_P(e)) {
return LONG2NUM(FIX2LONG(e) - 1);
}
View
2  test/ruby/test_range.rb
@@ -68,6 +68,8 @@ def test_max
assert_equal(2.0, (1.0..2.0).max)
assert_equal(nil, (2.0..1.0).max)
assert_raise(TypeError) { (1.0...2.0).max }
+ assert_raise(TypeError) { (1...1.5).max }
+ assert_raise(TypeError) { (1.5...2).max }
assert_equal(-0x80000002, ((-0x80000002)...(-0x80000001)).max)
Please sign in to comment.
Something went wrong with that request. Please try again.