1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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/trunk@24405 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2009-08-05 05:01:12 +00:00
parent c82826ce5f
commit da19797648
3 changed files with 14 additions and 2 deletions

View file

@ -72,6 +72,14 @@ Tue Aug 4 12:40:45 2009 NARUSE, Yui <naruse@ruby-lang.org>
* enc/encdb.c (ENC_SET_BASE): fix typo.
patch by ujihisa [ruby-dev:39004]
Tue Aug 4 11:57:39 2009 Yukihiro Matsumoto <matz@ruby-lang.org>
* 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.
Tue Aug 4 09:41:11 2009 NARUSE, Yui <naruse@ruby-lang.org>
* enc/big5.c (EncLen_Big5): back to original Big5 table.

View file

@ -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)))

View file

@ -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