mirror of
https://github.com/ruby/ruby.git
synced 2025-09-23 20:44:00 +02:00
* variable.c (rb_mod_class_variables): return inherited variables
except when the optional argument is set to false. [ruby-dev:44034] [Bug #4971] * variable.c (rb_mod_constants): fix typo in documentation. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36466 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
0e60c71038
commit
1f03c90dbf
5 changed files with 93 additions and 14 deletions
|
@ -1356,4 +1356,16 @@ class TestModule < Test::Unit::TestCase
|
|||
assert_equal([:m1], Class.new{ prepend Module.new; def m1; end }.instance_methods(false), bug6660)
|
||||
assert_equal([:m1], Class.new(Class.new{def m2;end}){ prepend Module.new; def m1; end }.instance_methods(false), bug6660)
|
||||
end
|
||||
|
||||
def test_class_variables
|
||||
m = Module.new
|
||||
m.class_variable_set(:@@foo, 1)
|
||||
m2 = Module.new
|
||||
m2.send(:include, m)
|
||||
m2.class_variable_set(:@@bar, 2)
|
||||
assert_equal([:@@foo], m.class_variables)
|
||||
assert_equal([:@@bar, :@@foo], m2.class_variables)
|
||||
assert_equal([:@@bar, :@@foo], m2.class_variables(true))
|
||||
assert_equal([:@@bar], m2.class_variables(false))
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue