Skip to content

Commit 30255b3

Browse files
committed
Fix zombifier on memoized methods
* 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.
1 parent 7ee17ba commit 30255b3

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

Changelog.md

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
1+
# v0.12.6 unreleased
2+
3+
* [#1456](https://github.com/mbj/mutant/pull/1456)
4+
Fix zombified mutant on memoized methods (only relevant for mutant developers).
5+
16
# v0.12.4 2024-06-30
27

3-
* [#1455](https://github.com/mbj/mutant/pull/1454)
8+
* [#1455](https://github.com/mbj/mutant/pull/1455)
49

510
Fix parsing of empty rspec descriptions
611

712
# v0.12.3 2024-06-10
813

9-
* [#1452](https://github.com/mbj/mutant/pull/1451)
14+
* [#1452](https://github.com/mbj/mutant/pull/1452)
1015

1116
Remove support for EOL Ruby-3.0.
1217
Remove another invalid mutation to super().

lib/mutant/matcher/method/instance.rb

+6-1
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,13 @@ def self.new(scope:, target_method:)
3030
end
3131
# rubocop:enable Metrics/MethodLength
3232

33+
TARGET_MEMOIZER = ::Mutant::Adamantium
34+
35+
private_constant(*constants(false))
36+
37+
# mutant:disable - very hard for zombie
3338
def self.memoized_method?(scope, method_name)
34-
scope.raw < Adamantium && scope.raw.memoized?(method_name)
39+
scope.raw < TARGET_MEMOIZER && scope.raw.memoized?(method_name)
3540
end
3641
private_class_method :memoized_method?
3742

0 commit comments

Comments
 (0)