ruby-changes:32549
From: nobu <ko1@a...>
Date: Fri, 17 Jan 2014 17:58:16 +0900 (JST)
Subject: [ruby-changes:32549] nobu:r44628 (trunk): eval.c: singleton class constants
nobu 2014-01-17 17:58:05 +0900 (Fri, 17 Jan 2014) New Revision: 44628 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=44628 Log: eval.c: singleton class constants * eval.c (rb_mod_s_constants): return its own constants for other than Module itself. [ruby-core:59763] [Bug #9413] Modified files: trunk/ChangeLog trunk/eval.c trunk/test/ruby/test_module.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 44627) +++ ChangeLog (revision 44628) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Fri Jan 17 17:58:04 2014 Nobuyoshi Nakada <nobu@r...> + + * eval.c (rb_mod_s_constants): return its own constants for other + than Module itself. [ruby-core:59763] [Bug #9413] + Tue Jan 16 00:17:00 2014 Kenta Murata <mrkn@m...> * ext/bigdecimal/bigdecimal.gemspec: bigdecimal version 1.2.5. Index: eval.c =================================================================== --- eval.c (revision 44627) +++ eval.c (revision 44628) @@ -378,8 +378,8 @@ rb_mod_s_constants(int argc, VALUE *argv https://github.com/ruby/ruby/blob/trunk/eval.c#L378 VALUE cbase = 0; void *data = 0; - if (argc > 0) { - return rb_mod_constants(argc, argv, rb_cModule); + if (argc > 0 || mod != rb_cModule) { + return rb_mod_constants(argc, argv, mod); } while (cref) { Index: test/ruby/test_module.rb =================================================================== --- test/ruby/test_module.rb (revision 44627) +++ test/ruby/test_module.rb (revision 44628) @@ -866,6 +866,19 @@ class TestModule < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_module.rb#L866 m.instance_eval { remove_const(:Foo) } end + class Bug9413 + class << self + Foo = :foo + end + end + + def test_singleton_constants + bug9413 = '[ruby-core:59763] [Bug #9413]' + c = Bug9413.singleton_class + assert_include(c.constants(true), :Foo, bug9413) + assert_include(c.constants(false), :Foo, bug9413) + end + def test_frozen_class m = Module.new m.freeze -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/