From f029dba59b20c081e9b278dc754601555cccd3d0 Mon Sep 17 00:00:00 2001 From: yugui Date: Fri, 27 Nov 2009 02:54:29 +0000 Subject: merges r25010 from trunk into ruby_1_9_1 and adds tests for it. -- * struct.c (rb_struct_equal, rb_struct_eql): Handle comparison of recursive structures [ruby-core:24759] * range.c (range_eq, range_eql): ditto for ranges -- test for r25010 * test/ruby/test_struct.rb (TestStruct#test_comparison_when_recursive): new test. * test/ruby/test_range.rb (TestRange#test_comparison_when_recursive): new test. git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_9_1@25943 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_range.rb | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'test/ruby/test_range.rb') diff --git a/test/ruby/test_range.rb b/test/ruby/test_range.rb index 9dfd29012..dabe7fab8 100644 --- a/test/ruby/test_range.rb +++ b/test/ruby/test_range.rb @@ -1,4 +1,5 @@ require 'test/unit' +require 'timeout' class TestRange < Test::Unit::TestCase def test_range_string @@ -280,4 +281,37 @@ class TestRange < Test::Unit::TestCase o.instance_eval { initialize(o, 1) } assert_equal("(... .. ...)..1", o.inspect) end + + def test_comparison_when_recursive + x = CyclicRange.allocate; x.send(:initialize, x, 1) + y = CyclicRange.allocate; y.send(:initialize, y, 1) + Timeout.timeout(1) { + assert x == y + assert x.eql? y + } + + z = CyclicRange.allocate; z.send(:initialize, z, :another) + Timeout.timeout(1) { + assert x != z + assert !x.eql?(z) + } + + x = CyclicRange.allocate + y = CyclicRange.allocate + x.send(:initialize, y, 1) + y.send(:initialize, x, 1) + Timeout.timeout(1) { + assert x == y + assert x.eql?(y) + } + + x = CyclicRange.allocate + z = CyclicRange.allocate + x.send(:initialize, z, 1) + z.send(:initialize, x, :other) + Timeout.timeout(1) { + assert x != z + assert !x.eql?(z) + } + end end -- cgit