File tree Expand file tree Collapse file tree 2 files changed +73
-11
lines changed
Sources/MockingMacros/Macros/MockedMacro
Tests/MockingMacrosTests/Macros/MockedMacro Expand file tree Collapse file tree 2 files changed +73
-11
lines changed Original file line number Diff line number Diff line change @@ -328,14 +328,6 @@ extension MockedMacro {
328328 ofType: IfConfigDeclSyntax . self
329329 )
330330
331- let mockedIfConfigDeclarations : [ IfConfigDeclSyntax ] = try ifConfigDeclarations. compactMap {
332- try self . mockIfConfigDeclaration (
333- from: $0,
334- with: accessLevel,
335- in: protocolDeclaration
336- )
337- }
338-
339331 return try MemberBlockSyntax {
340332 for initializerDeclaration in initializerDeclarations {
341333 try self . mockInitializerConformanceDeclaration (
@@ -362,8 +354,14 @@ extension MockedMacro {
362354 )
363355 }
364356
365- for mockedIfConfig in mockedIfConfigDeclarations {
366- mockedIfConfig
357+ for ifConfigDeclaration in ifConfigDeclarations {
358+ if let mockedIfConfig = try self . mockIfConfigDeclaration (
359+ from: ifConfigDeclaration,
360+ with: accessLevel,
361+ in: protocolDeclaration
362+ ) {
363+ mockedIfConfig
364+ }
367365 }
368366 }
369367 }
@@ -703,7 +701,7 @@ extension MockedMacro {
703701 MemberBlockItemSyntax ( decl: mockedIfConfig)
704702 }
705703 }
706- // AssociatedTypeDeclSyntax is intentionally skipped here since
704+ // AssociatedTypeDeclSyntax is intentionally skipped since
707705 // associated types become generic parameters on the mock class.
708706 }
709707 }
Original file line number Diff line number Diff line change @@ -230,5 +230,69 @@ struct Mocked_IfConfigDeclTests {
230230 """
231231 )
232232 }
233+
234+ // MARK: OR Condition Tests
235+
236+ @Test ( arguments: mockedTestConfigurations)
237+ func orCondition(
238+ interface: InterfaceConfiguration ,
239+ mock: MockConfiguration
240+ ) {
241+ assertMocked (
242+ """
243+ \( interface. accessLevel) protocol Dependency {
244+ func commonMethod()
245+ #if DEBUG || TESTFLIGHT
246+ func debugOrTestFlightMethod()
247+ #endif
248+ }
249+ """ ,
250+ generates: """
251+ #if SWIFT_MOCKING_ENABLED
252+ @MockedMembers
253+ \( mock. modifiers) class DependencyMock: Dependency {
254+ \( mock. memberModifiers) func commonMethod()
255+ #if DEBUG || TESTFLIGHT
256+ \( mock. memberModifiers) func debugOrTestFlightMethod()
257+ #endif
258+ }
259+ #endif
260+ """
261+ )
262+ }
263+
264+ // MARK: Nested #if Conditional Tests
265+
266+ @Test ( arguments: mockedTestConfigurations)
267+ func nestedIfConditionals(
268+ interface: InterfaceConfiguration ,
269+ mock: MockConfiguration
270+ ) {
271+ assertMocked (
272+ """
273+ \( interface. accessLevel) protocol Dependency {
274+ #if DEBUG
275+ func debugMethod()
276+ #if os(iOS)
277+ func debugiOSOnlyMethod()
278+ #endif
279+ #endif
280+ }
281+ """ ,
282+ generates: """
283+ #if SWIFT_MOCKING_ENABLED
284+ @MockedMembers
285+ \( mock. modifiers) class DependencyMock: Dependency {
286+ #if DEBUG
287+ \( mock. memberModifiers) func debugMethod()
288+ #if os(iOS)
289+ \( mock. memberModifiers) func debugiOSOnlyMethod()
290+ #endif
291+ #endif
292+ }
293+ #endif
294+ """
295+ )
296+ }
233297}
234298#endif
You can’t perform that action at this time.
0 commit comments