Skip to content

Commit 4515383

Browse files
committed
update tests
1 parent 9d491ef commit 4515383

File tree

1 file changed

+127
-13
lines changed

1 file changed

+127
-13
lines changed

Tests/ComposableArchitectureMacrosTests/ObservableStateMacroTests.swift

Lines changed: 127 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77

88
final class ObservableStateMacroTests: MacroBaseTestCase {
99
override func invokeTest() {
10-
withMacroTesting {
10+
withMacroTesting(
11+
// record: .failed,
12+
) {
1113
super.invokeTest()
1214
}
1315
}
@@ -35,14 +37,18 @@
3537
return _count
3638
}
3739
set {
40+
guard shouldNotifyObservers(_count, newValue) else {
41+
return
42+
}
3843
_$observationRegistrar.mutate(self, keyPath: \.count, &_count, newValue, _$isIdentityEqual)
3944
}
4045
_modify {
4146
let oldValue = _$observationRegistrar.willModify(self, keyPath: \.count, &_count)
42-
defer {
43-
_$observationRegistrar.didModify(self, keyPath: \.count, &_count, oldValue, _$isIdentityEqual)
44-
}
4547
yield &_count
48+
guard shouldNotifyObservers(oldValue, count) else {
49+
return
50+
}
51+
_$observationRegistrar.didModify(self, keyPath: \.count, &_count, oldValue, _$isIdentityEqual)
4652
}
4753
}
4854
@@ -55,6 +61,22 @@
5561
public mutating func _$willModify() {
5662
_$observationRegistrar._$willModify()
5763
}
64+
65+
private nonisolated func shouldNotifyObservers<__macro_local_6MemberfMu_>(_ lhs: __macro_local_6MemberfMu_, _ rhs: __macro_local_6MemberfMu_) -> Bool {
66+
true
67+
}
68+
69+
private nonisolated func shouldNotifyObservers<__macro_local_6MemberfMu0_: Equatable>(_ lhs: __macro_local_6MemberfMu0_, _ rhs: __macro_local_6MemberfMu0_) -> Bool {
70+
lhs != rhs
71+
}
72+
73+
private nonisolated func shouldNotifyObservers<__macro_local_6MemberfMu1_: AnyObject>(_ lhs: __macro_local_6MemberfMu1_, _ rhs: __macro_local_6MemberfMu1_) -> Bool {
74+
lhs !== rhs
75+
}
76+
77+
private nonisolated func shouldNotifyObservers<__macro_local_6MemberfMu2_: Equatable & AnyObject>(_ lhs: __macro_local_6MemberfMu2_, _ rhs: __macro_local_6MemberfMu2_) -> Bool {
78+
lhs != rhs
79+
}
5880
}
5981
"""#
6082
}
@@ -81,14 +103,18 @@
81103
return _count
82104
}
83105
set {
106+
guard shouldNotifyObservers(_count, newValue) else {
107+
return
108+
}
84109
_$observationRegistrar.mutate(self, keyPath: \.count, &_count, newValue, _$isIdentityEqual)
85110
}
86111
_modify {
87112
let oldValue = _$observationRegistrar.willModify(self, keyPath: \.count, &_count)
88-
defer {
89-
_$observationRegistrar.didModify(self, keyPath: \.count, &_count, oldValue, _$isIdentityEqual)
90-
}
91113
yield &_count
114+
guard shouldNotifyObservers(oldValue, count) else {
115+
return
116+
}
117+
_$observationRegistrar.didModify(self, keyPath: \.count, &_count, oldValue, _$isIdentityEqual)
92118
}
93119
}
94120
@@ -101,6 +127,22 @@
101127
public mutating func _$willModify() {
102128
_$observationRegistrar._$willModify()
103129
}
130+
131+
private nonisolated func shouldNotifyObservers<__macro_local_6MemberfMu_>(_ lhs: __macro_local_6MemberfMu_, _ rhs: __macro_local_6MemberfMu_) -> Bool {
132+
true
133+
}
134+
135+
private nonisolated func shouldNotifyObservers<__macro_local_6MemberfMu0_: Equatable>(_ lhs: __macro_local_6MemberfMu0_, _ rhs: __macro_local_6MemberfMu0_) -> Bool {
136+
lhs != rhs
137+
}
138+
139+
private nonisolated func shouldNotifyObservers<__macro_local_6MemberfMu1_: AnyObject>(_ lhs: __macro_local_6MemberfMu1_, _ rhs: __macro_local_6MemberfMu1_) -> Bool {
140+
lhs !== rhs
141+
}
142+
143+
private nonisolated func shouldNotifyObservers<__macro_local_6MemberfMu2_: Equatable & AnyObject>(_ lhs: __macro_local_6MemberfMu2_, _ rhs: __macro_local_6MemberfMu2_) -> Bool {
144+
lhs != rhs
145+
}
104146
}
105147
"""#
106148
}
@@ -127,14 +169,18 @@
127169
return _count
128170
}
129171
set {
172+
guard shouldNotifyObservers(_count, newValue) else {
173+
return
174+
}
130175
_$observationRegistrar.mutate(self, keyPath: \.count, &_count, newValue, _$isIdentityEqual)
131176
}
132177
_modify {
133178
let oldValue = _$observationRegistrar.willModify(self, keyPath: \.count, &_count)
134-
defer {
135-
_$observationRegistrar.didModify(self, keyPath: \.count, &_count, oldValue, _$isIdentityEqual)
136-
}
137179
yield &_count
180+
guard shouldNotifyObservers(oldValue, count) else {
181+
return
182+
}
183+
_$observationRegistrar.didModify(self, keyPath: \.count, &_count, oldValue, _$isIdentityEqual)
138184
}
139185
}
140186
@@ -147,6 +193,22 @@
147193
public mutating func _$willModify() {
148194
_$observationRegistrar._$willModify()
149195
}
196+
197+
private nonisolated func shouldNotifyObservers<__macro_local_6MemberfMu_>(_ lhs: __macro_local_6MemberfMu_, _ rhs: __macro_local_6MemberfMu_) -> Bool {
198+
true
199+
}
200+
201+
private nonisolated func shouldNotifyObservers<__macro_local_6MemberfMu0_: Equatable>(_ lhs: __macro_local_6MemberfMu0_, _ rhs: __macro_local_6MemberfMu0_) -> Bool {
202+
lhs != rhs
203+
}
204+
205+
private nonisolated func shouldNotifyObservers<__macro_local_6MemberfMu1_: AnyObject>(_ lhs: __macro_local_6MemberfMu1_, _ rhs: __macro_local_6MemberfMu1_) -> Bool {
206+
lhs !== rhs
207+
}
208+
209+
private nonisolated func shouldNotifyObservers<__macro_local_6MemberfMu2_: Equatable & AnyObject>(_ lhs: __macro_local_6MemberfMu2_, _ rhs: __macro_local_6MemberfMu2_) -> Bool {
210+
lhs != rhs
211+
}
150212
}
151213
"""#
152214
}
@@ -170,14 +232,18 @@
170232
return _count
171233
}
172234
set {
235+
guard shouldNotifyObservers(_count, newValue) else {
236+
return
237+
}
173238
_$observationRegistrar.mutate(self, keyPath: \.count, &_count, newValue, _$isIdentityEqual)
174239
}
175240
_modify {
176241
let oldValue = _$observationRegistrar.willModify(self, keyPath: \.count, &_count)
177-
defer {
178-
_$observationRegistrar.didModify(self, keyPath: \.count, &_count, oldValue, _$isIdentityEqual)
179-
}
180242
yield &_count
243+
guard shouldNotifyObservers(oldValue, count) else {
244+
return
245+
}
246+
_$observationRegistrar.didModify(self, keyPath: \.count, &_count, oldValue, _$isIdentityEqual)
181247
}
182248
}
183249
@@ -190,6 +256,22 @@
190256
public mutating func _$willModify() {
191257
_$observationRegistrar._$willModify()
192258
}
259+
260+
private nonisolated func shouldNotifyObservers<__macro_local_6MemberfMu_>(_ lhs: __macro_local_6MemberfMu_, _ rhs: __macro_local_6MemberfMu_) -> Bool {
261+
true
262+
}
263+
264+
private nonisolated func shouldNotifyObservers<__macro_local_6MemberfMu0_: Equatable>(_ lhs: __macro_local_6MemberfMu0_, _ rhs: __macro_local_6MemberfMu0_) -> Bool {
265+
lhs != rhs
266+
}
267+
268+
private nonisolated func shouldNotifyObservers<__macro_local_6MemberfMu1_: AnyObject>(_ lhs: __macro_local_6MemberfMu1_, _ rhs: __macro_local_6MemberfMu1_) -> Bool {
269+
lhs !== rhs
270+
}
271+
272+
private nonisolated func shouldNotifyObservers<__macro_local_6MemberfMu2_: Equatable & AnyObject>(_ lhs: __macro_local_6MemberfMu2_, _ rhs: __macro_local_6MemberfMu2_) -> Bool {
273+
lhs != rhs
274+
}
193275
}
194276
"""#
195277
}
@@ -218,6 +300,22 @@
218300
public mutating func _$willModify() {
219301
_$observationRegistrar._$willModify()
220302
}
303+
304+
private nonisolated func shouldNotifyObservers<__macro_local_6MemberfMu_>(_ lhs: __macro_local_6MemberfMu_, _ rhs: __macro_local_6MemberfMu_) -> Bool {
305+
true
306+
}
307+
308+
private nonisolated func shouldNotifyObservers<__macro_local_6MemberfMu0_: Equatable>(_ lhs: __macro_local_6MemberfMu0_, _ rhs: __macro_local_6MemberfMu0_) -> Bool {
309+
lhs != rhs
310+
}
311+
312+
private nonisolated func shouldNotifyObservers<__macro_local_6MemberfMu1_: AnyObject>(_ lhs: __macro_local_6MemberfMu1_, _ rhs: __macro_local_6MemberfMu1_) -> Bool {
313+
lhs !== rhs
314+
}
315+
316+
private nonisolated func shouldNotifyObservers<__macro_local_6MemberfMu2_: Equatable & AnyObject>(_ lhs: __macro_local_6MemberfMu2_, _ rhs: __macro_local_6MemberfMu2_) -> Bool {
317+
lhs != rhs
318+
}
221319
}
222320
"""
223321
}
@@ -673,6 +771,22 @@
673771
public mutating func _$willModify() {
674772
_$observationRegistrar._$willModify()
675773
}
774+
775+
private nonisolated func shouldNotifyObservers<__macro_local_6MemberfMu_>(_ lhs: __macro_local_6MemberfMu_, _ rhs: __macro_local_6MemberfMu_) -> Bool {
776+
true
777+
}
778+
779+
private nonisolated func shouldNotifyObservers<__macro_local_6MemberfMu0_: Equatable>(_ lhs: __macro_local_6MemberfMu0_, _ rhs: __macro_local_6MemberfMu0_) -> Bool {
780+
lhs != rhs
781+
}
782+
783+
private nonisolated func shouldNotifyObservers<__macro_local_6MemberfMu1_: AnyObject>(_ lhs: __macro_local_6MemberfMu1_, _ rhs: __macro_local_6MemberfMu1_) -> Bool {
784+
lhs !== rhs
785+
}
786+
787+
private nonisolated func shouldNotifyObservers<__macro_local_6MemberfMu2_: Equatable & AnyObject>(_ lhs: __macro_local_6MemberfMu2_, _ rhs: __macro_local_6MemberfMu2_) -> Bool {
788+
lhs != rhs
789+
}
676790
}
677791
"""
678792
}

0 commit comments

Comments
 (0)