Skip to content

Commit 620132a

Browse files
committed
Fix test
1 parent 41a262c commit 620132a

File tree

4 files changed

+9
-13
lines changed

4 files changed

+9
-13
lines changed

Sources/ComposableArchitecture/Observation/ObservationStateRegistrar.swift

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,12 @@ extension ObservationStateRegistrar: Equatable, Hashable, Codable {
5252
_ value: inout Value,
5353
_ newValue: Value,
5454
_ isIdentityEqual: (Value, Value) -> Bool,
55-
_ shouldNotifyObservers: (Value, Value) -> Bool
55+
_ shouldNotifyObservers: (Value, Value) -> Bool = { _, _ in true }
5656
) {
57-
if isIdentityEqual(value, newValue) {
57+
if isIdentityEqual(value, newValue) || !shouldNotifyObservers(value, newValue) {
5858
value = newValue
5959
} else {
60-
if shouldNotifyObservers(value, newValue) {
61-
self.registrar.withMutation(of: subject, keyPath: keyPath) {
62-
value = newValue
63-
}
64-
} else {
60+
self.registrar.withMutation(of: subject, keyPath: keyPath) {
6561
value = newValue
6662
}
6763
}

Sources/ComposableArchitectureMacros/ObservableStateMacro.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ public struct ObservationStateTrackedMacro: AccessorMacro {
654654
_modify {
655655
let oldValue = _$observationRegistrar.willModify(self, keyPath: \\.\(identifier), &_\(identifier))
656656
defer {
657-
_$observationRegistrar.didModify(self, keyPath: \\.\(identifier), &_\(identifier), oldValue, _$isIdentityEqual, shouldNotifyObservers)
657+
_$observationRegistrar.didModify(self, keyPath: \\.\(identifier), &_\(identifier), oldValue, _$isIdentityEqual)
658658
}
659659
yield &_\(identifier)
660660
}

Tests/ComposableArchitectureMacrosTests/MacroBaseTestCase.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
class MacroBaseTestCase: XCTestCase {
99
override func invokeTest() {
1010
MacroTesting.withMacroTesting(
11-
//isRecording: true,
11+
record: .failed,
1212
macros: [
1313
ObservableStateMacro.self,
1414
ObservationStateTrackedMacro.self,

Tests/ComposableArchitectureMacrosTests/ObservableStateMacroTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
_modify {
4343
let oldValue = _$observationRegistrar.willModify(self, keyPath: \.count, &_count)
4444
defer {
45-
_$observationRegistrar.didModify(self, keyPath: \.count, &_count, oldValue, _$isIdentityEqual, shouldNotifyObservers)
45+
_$observationRegistrar.didModify(self, keyPath: \.count, &_count, oldValue, _$isIdentityEqual)
4646
}
4747
yield &_count
4848
}
@@ -104,7 +104,7 @@
104104
_modify {
105105
let oldValue = _$observationRegistrar.willModify(self, keyPath: \.count, &_count)
106106
defer {
107-
_$observationRegistrar.didModify(self, keyPath: \.count, &_count, oldValue, _$isIdentityEqual, shouldNotifyObservers)
107+
_$observationRegistrar.didModify(self, keyPath: \.count, &_count, oldValue, _$isIdentityEqual)
108108
}
109109
yield &_count
110110
}
@@ -166,7 +166,7 @@
166166
_modify {
167167
let oldValue = _$observationRegistrar.willModify(self, keyPath: \.count, &_count)
168168
defer {
169-
_$observationRegistrar.didModify(self, keyPath: \.count, &_count, oldValue, _$isIdentityEqual, shouldNotifyObservers)
169+
_$observationRegistrar.didModify(self, keyPath: \.count, &_count, oldValue, _$isIdentityEqual)
170170
}
171171
yield &_count
172172
}
@@ -225,7 +225,7 @@
225225
_modify {
226226
let oldValue = _$observationRegistrar.willModify(self, keyPath: \.count, &_count)
227227
defer {
228-
_$observationRegistrar.didModify(self, keyPath: \.count, &_count, oldValue, _$isIdentityEqual, shouldNotifyObservers)
228+
_$observationRegistrar.didModify(self, keyPath: \.count, &_count, oldValue, _$isIdentityEqual)
229229
}
230230
yield &_count
231231
}

0 commit comments

Comments
 (0)