diff options
author | Koichi Sasada <ko1@atdot.net> | 2019-09-30 15:36:19 +0900 |
---|---|---|
committer | Koichi Sasada <ko1@atdot.net> | 2019-09-30 15:36:19 +0900 |
commit | 88f38c187e3171f8f351f3198247d20ea9f016ee (patch) | |
tree | b127238144e0ba63a3a809816b34daaa27a82266 /test/ruby | |
parent | bf8d7d9c1d89a62537566ea6dd43db175a892dbd (diff) | |
download | ruby-88f38c187e3171f8f351f3198247d20ea9f016ee.tar.gz |
Emulate method_list (chkbuild) on test-all.
chkbuild (CI process) shows methods list before
running tests and sometimes it can fails. This
commit a code part to emulate this method listing
feature.
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/test_method.rb | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/test/ruby/test_method.rb b/test/ruby/test_method.rb index a141202014..fe1df15d29 100644 --- a/test/ruby/test_method.rb +++ b/test/ruby/test_method.rb @@ -1169,4 +1169,45 @@ class TestMethod < Test::Unit::TestCase plus = Integer.instance_method(:+) assert_equal(3, plus.bind_call(1, 2)) end + + def test_method_list + # chkbuild lists all methods. + # The following code emulate this listing. + + use_symbol = Object.instance_methods[0].is_a?(Symbol) + nummodule = nummethod = 0 + mods = [] + ObjectSpace.each_object(Module) {|m| mods << m if m.name } + mods = mods.sort_by {|m| m.name } + mods.each {|mod| + nummodule += 1 + mc = mod.kind_of?(Class) ? "class" : "module" + puts_line = "#{mc} #{mod.name} #{(mod.ancestors - [mod]).inspect}" + mod.singleton_methods(false).sort.each {|methname| + nummethod += 1 + meth = mod.method(methname) + line = "#{mod.name}.#{methname} #{meth.arity}" + line << " not-implemented" if !mod.respond_to?(methname) + # puts line + } + ms = mod.instance_methods(false) + if use_symbol + ms << :initialize if mod.private_instance_methods(false).include? :initialize + else + ms << "initialize" if mod.private_instance_methods(false).include? "initialize" + end + + ms.sort.each {|methname| + nummethod += 1 + meth = mod.instance_method(methname) + line = "#{mod.name}\##{methname} #{meth.arity}" + line << " not-implemented" if /\(not-implemented\)/ =~ meth.inspect + # puts line + } + } + # puts "#{nummodule} modules, #{nummethod} methods" + + assert nummodule > 0 + assert nummethod > 0 + end end |