diff options
author | Koichi Sasada <ko1@atdot.net> | 2019-08-09 11:00:34 +0900 |
---|---|---|
committer | Koichi Sasada <ko1@atdot.net> | 2019-08-09 11:05:11 +0900 |
commit | 71efad1ed391ee0c5398a76306fdbaaadd4dc52e (patch) | |
tree | d560b4a717ee7d15d23dc4ea02b1708f7d1d71ea /test/ruby/test_class.rb | |
parent | c7acb37248d4cef76647f8bc7ebd7dc291d9a853 (diff) | |
download | ruby-71efad1ed391ee0c5398a76306fdbaaadd4dc52e.tar.gz |
introduce RCLASS_CLONED flag for inline cache.
Methods on duplicated class/module refer same constant inline
cache (IC). Constant access lookup should be done for cloned
class/modules but inline cache doesn't check it.
To check it, this patch introduce new RCLASS_CLONED flag which
are set when if class/module is cloned (both orig and dst).
[Bug #15877]
Diffstat (limited to 'test/ruby/test_class.rb')
-rw-r--r-- | test/ruby/test_class.rb | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/test/ruby/test_class.rb b/test/ruby/test_class.rb index 93278a918f..f07a1cdc40 100644 --- a/test/ruby/test_class.rb +++ b/test/ruby/test_class.rb @@ -329,18 +329,22 @@ class TestClass < Test::Unit::TestCase end; end - module M - C = 1 + class CloneTest + def foo; TEST; end + end - def self.m - C - end + CloneTest1 = CloneTest.clone + CloneTest2 = CloneTest.clone + class CloneTest1 + TEST = :C1 + end + class CloneTest2 + TEST = :C2 end - def test_constant_access_from_method_in_cloned_module # [ruby-core:47834] - m = M.dup - assert_equal 1, m::C - assert_equal 1, m.m + def test_constant_access_from_method_in_cloned_class + assert_equal :C1, CloneTest1.new.foo, '[Bug #15877]' + assert_equal :C2, CloneTest2.new.foo, '[Bug #15877]' end def test_invalid_superclass |