diff options
author | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-05-15 15:24:05 +0000 |
---|---|---|
committer | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-05-15 15:24:05 +0000 |
commit | 67f5f1be206c7ecb19aeb4cb1167dcedfb3466bd (patch) | |
tree | a58a203998f29867fc31696d482a42222ffbf92a /test/ruby/test_alias.rb | |
parent | d5cf6c1128d04beb84ac960ec5855f2fb64f3d27 (diff) |
merge revision(s) r45367,r45387,r45388,r45389: [Backport #9475]
* vm_method.c (rb_method_entry_get_without_cache): get rid of
infinite recursion at aliases in a subclass and a superclass.
return actually defined class for other than singleton class.
[ruby-core:60431] [Bug #9475]
* vm_method.c (rb_method_entry_get_without_cache): me->klass is 0
for a method aliased in a module. [ruby-core:61636] [Bug #9663]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45955 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_alias.rb')
-rw-r--r-- | test/ruby/test_alias.rb | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/test/ruby/test_alias.rb b/test/ruby/test_alias.rb index 956fdb41f0..dec61f6d63 100644 --- a/test/ruby/test_alias.rb +++ b/test/ruby/test_alias.rb @@ -132,4 +132,66 @@ class TestAlias < Test::Unit::TestCase GC.verify_internal_consistency } end + + def test_cyclic_zsuper + bug9475 = '[ruby-core:60431] [Bug #9475]' + + a = Module.new do + def foo + "A" + end + end + + b = Class.new do + include a + attr_reader :b + + def foo + @b ||= 0 + raise SystemStackError if (@b += 1) > 1 + # "foo from B" + super + "B" + end + end + + c = Class.new(b) do + alias orig_foo foo + + def foo + # "foo from C" + orig_foo + "C" + end + end + + b.class_eval do + alias orig_foo foo + attr_reader :b2 + + def foo + @b2 ||= 0 + raise SystemStackError if (@b2 += 1) > 1 + # "foo from B (again)" + orig_foo + "B2" + end + end + + assert_nothing_raised(SystemStackError, bug9475) do + assert_equal("ABC", c.new.foo, bug9475) + end + end + + def test_alias_in_module + bug9663 = '[ruby-core:61635] [Bug #9663]' + + assert_separately(['-', bug9663], <<-'end;') + bug = ARGV[0] + + m = Module.new do + alias orig_to_s to_s + end + + o = Object.new.extend(m) + assert_equal(o.to_s, o.orig_to_s, bug) + end; + end end |