diff options
author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-08-08 15:34:26 +0000 |
---|---|---|
committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-08-08 15:34:26 +0000 |
commit | 48500e49b74882605d6d19f3263442c07b4de188 (patch) | |
tree | fbb0d2d427fcc35a13169bded7cdd46ffd6fe0b6 | |
parent | 4ef1f3eafe471c38aa4f748478c480dcfc5000b7 (diff) |
merges r24405 from trunk into ruby_1_9_1.
--
* range.c (range_eql, range_eq): fixed equality to work for
subclasses of Range. a patch from Marc-Andre Lafortune.
[ruby-core:22190]
* test/ruby/test_range.rb: add assertions for above.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@24469 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | range.c | 4 | ||||
-rw-r--r-- | test/ruby/test_range.rb | 4 | ||||
-rw-r--r-- | version.h | 2 |
3 files changed, 7 insertions, 3 deletions
@@ -125,7 +125,7 @@ range_eq(VALUE range, VALUE obj) { if (range == obj) return Qtrue; - if (!rb_obj_is_instance_of(obj, rb_obj_class(range))) + if (!rb_obj_is_kind_of(obj, rb_cRange)) return Qfalse; if (!rb_equal(RANGE_BEG(range), RANGE_BEG(obj))) @@ -187,7 +187,7 @@ range_eql(VALUE range, VALUE obj) { if (range == obj) return Qtrue; - if (!rb_obj_is_instance_of(obj, rb_obj_class(range))) + if (!rb_obj_is_kind_of(obj, rb_cRange)) return Qfalse; if (!rb_eql(RANGE_BEG(range), RANGE_BEG(obj))) diff --git a/test/ruby/test_range.rb b/test/ruby/test_range.rb index b4c078915d..9dfd29012a 100644 --- a/test/ruby/test_range.rb +++ b/test/ruby/test_range.rb @@ -89,6 +89,8 @@ class TestRange < Test::Unit::TestCase assert(r != (1..2)) assert(r != (0..2)) assert(r != (0...1)) + subclass = Class.new(Range) + assert(r == subclass.new(0,1)) end def test_eql @@ -99,6 +101,8 @@ class TestRange < Test::Unit::TestCase assert(!r.eql?(1..2)) assert(!r.eql?(0..2)) assert(!r.eql?(0...1)) + subclass = Class.new(Range) + assert(r.eql?(subclass.new(0,1))) end def test_hash @@ -1,5 +1,5 @@ #define RUBY_VERSION "1.9.1" -#define RUBY_PATCHLEVEL 273 +#define RUBY_PATCHLEVEL 274 #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 9 #define RUBY_VERSION_TEENY 1 |