Skip to content

Commit

Permalink
Fix zombifier on memoized methods
Browse files Browse the repository at this point in the history
* When mutant runs zombified (for self tests) the `Zombie::Mutant` namespace tests
  the `Mutant` namespace.
* So when the `Zombie::Mutant` runs it has to be able to reference the "regular" `Adamantium` not the
  zombified when testing if a memoized method has to be unwound.
  • Loading branch information
mbj committed Oct 15, 2024
1 parent 8bcbafe commit 2988ea6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
6 changes: 6 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# v0.12.5 unreleased

* [#1458](https://github.com/mbj/mutant/pull/1458)

Fix zombifier on memoized methods (only relevant for mutant developers).

# v0.12.4 2024-06-30

* [#1455](https://github.com/mbj/mutant/pull/1455)
Expand Down
6 changes: 5 additions & 1 deletion lib/mutant/matcher/method/instance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@ def self.new(scope:, target_method:)
end
# rubocop:enable Metrics/MethodLength

TARGET_MEMOIZER = ::Mutant::Adamantium

private_constant(*constants(false))

def self.memoized_method?(scope, method_name)
scope.raw < Adamantium && scope.raw.memoized?(method_name)
scope.raw < TARGET_MEMOIZER && scope.raw.memoized?(method_name)
end
private_class_method :memoized_method?

Expand Down

0 comments on commit 2988ea6

Please sign in to comment.