diff options
| author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-11-27 02:54:29 +0000 |
|---|---|---|
| committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-11-27 02:54:29 +0000 |
| commit | f029dba59b20c081e9b278dc754601555cccd3d0 (patch) | |
| tree | a0e48c71d1584691383297d9c7f46cdc300ad8a3 /test/ruby/test_range.rb | |
| parent | 10c992f436caa8110a2201d08f067273a6aa884a (diff) | |
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
Diffstat (limited to 'test/ruby/test_range.rb')
| -rw-r--r-- | test/ruby/test_range.rb | 34 |
1 files changed, 34 insertions, 0 deletions
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 |
