mirror of
https://github.com/ruby/ruby.git
synced 2026-01-26 12:14:51 +00:00
[ruby/rubygems] Use method_defined? instead of instance_methods.include?
While the latter creates an intermediate array of all method names including all ancestors, the former just traverse the inheritance chain and can stop if found once. https://github.com/ruby/rubygems/commit/b291070b3b
This commit is contained in:
parent
256b4722a0
commit
e39385bf84
@ -25,7 +25,7 @@ class TestGemExtCargoBuilderLinkFlagConverter < Gem::TestCase
|
||||
}.freeze
|
||||
|
||||
CASES.each do |test_name, (arg, expected)|
|
||||
raise "duplicate test name" if instance_methods.include?(test_name)
|
||||
raise "duplicate test name" if method_defined?(test_name)
|
||||
|
||||
define_method(test_name) do
|
||||
assert_equal(expected, Gem::Ext::CargoBuilder::LinkFlagConverter.convert(arg))
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
require_relative "package/tar_test_case"
|
||||
|
||||
unless Gem::Package::TarTestCase.instance_methods.include?(:assert_ractor)
|
||||
unless Gem::Package::TarTestCase.method_defined?(:assert_ractor)
|
||||
require "core_assertions"
|
||||
Gem::Package::TarTestCase.include Test::Unit::CoreAssertions
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user