From 04e75d90d9856ac698aa46b74689ea9b9e03e425 Mon Sep 17 00:00:00 2001 From: Earlopain <14981592+Earlopain@users.noreply.github.com> Date: Wed, 14 Jan 2026 08:43:04 +0100 Subject: [PATCH] Remove clearing the method cache It was added in https://github.com/ruby/power_assert/commit/ef6f12f8b27608c0be7cd538528995f105c02285 However, the added test passes without it in all supported ruby versions --- lib/power_assert.rb | 12 ------------ test/block_test.rb | 22 ++++++++++------------ 2 files changed, 10 insertions(+), 24 deletions(-) diff --git a/lib/power_assert.rb b/lib/power_assert.rb index 8de209e..035e0a9 100644 --- a/lib/power_assert.rb +++ b/lib/power_assert.rb @@ -28,7 +28,6 @@ module PowerAssert class << self def start(assertion_proc_or_source, assertion_method: nil, source_binding: TOPLEVEL_BINDING) - clear_global_method_cache yield Context.new(assertion_proc_or_source, assertion_method, source_binding) end @@ -48,16 +47,5 @@ def internal_file?(file) file.start_with?(dir) end end - - CLEAR_CACHE_ISEQ = RubyVM::InstructionSequence.compile('using PowerAssert.const_get(:Empty)') - private_constant :CLEAR_CACHE_ISEQ - - def clear_global_method_cache - CLEAR_CACHE_ISEQ.eval - end - end - - module Empty end - private_constant :Empty end diff --git a/test/block_test.rb b/test/block_test.rb index cd43a62..6b903e1 100644 --- a/test/block_test.rb +++ b/test/block_test.rb @@ -351,19 +351,17 @@ def inspect; '#'; end end end - if PowerAssert.respond_to?(:clear_global_method_cache, true) - t do - 3.times do - assert_equal <