summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYusuke Endoh <mame@ruby-lang.org>2022-01-04 17:34:28 +0900
committerYusuke Endoh <mame@ruby-lang.org>2022-01-04 17:34:28 +0900
commit426ddbfff5e3106db52456e2b91a23f2f1644872 (patch)
tree54a23f897c468cc69e1bd5ae0eba0d98d026af3c
parent47bf64a26d3d95a312ea5cf5d94ee1d2104f5e26 (diff)
test/ruby/test_method.rb: Fix a random failure during `make COVERAGE=1`
This fixes the following failure. ``` 1) Error: TestMethod#test_method_list: NoMethodError: undefined method `<=>' for #<BasicObject:0x00007f7757e7eb60> mods = mods.sort_by {|m| m.name } ^^^^^^^^ ``` https://github.com/ruby/actions/runs/4699487470?check_suite_focus=true TestNoMethodError#test_to_s creates an anonymous module whose `#name` method returns a BasicObject. https://github.com/ruby/ruby/blob/f0669fb6cbdbad499974252ef2d955a608d0adc1/test/ruby/test_nomethod_error.rb#L95-L99 TestMethod#test_method_list uses `ObjectSpace.each_object(Module)` to gather all Modules and attempts to sort them by `#name`. But the anonymous module returns a BasicObject, which leads to the test failure above.
-rw-r--r--test/ruby/test_method.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/test/ruby/test_method.rb b/test/ruby/test_method.rb
index 0da69fd4e4..8f68df7b24 100644
--- a/test/ruby/test_method.rb
+++ b/test/ruby/test_method.rb
@@ -1409,7 +1409,7 @@ class TestMethod < Test::Unit::TestCase
# use_symbol = Object.instance_methods[0].is_a?(Symbol)
nummodule = nummethod = 0
mods = []
- ObjectSpace.each_object(Module) {|m| mods << m if m.name }
+ ObjectSpace.each_object(Module) {|m| mods << m if Symbol === m.name }
mods = mods.sort_by {|m| m.name }
mods.each {|mod|
nummodule += 1