Skip to content

Commit 924d3cc

Browse files
authored
CI: remove some redundant #ifs in tests (#495)
1 parent 784dec0 commit 924d3cc

16 files changed

+1
-113
lines changed

Tests/Tests/ViewTypes/ButtonTests.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ import Testing
66
@MainActor
77
@Suite
88
struct ButtonTests {
9-
#if canImport(AppKit)
109
typealias PlatformButton = NSButton
11-
#endif
1210

1311
@available(macOS, introduced: 10.15, obsoleted: 26.0)
1412
@Test func introspectButtonsBeforeMacOS26() async throws {

Tests/Tests/ViewTypes/DatePickerWithFieldStyleTests.swift

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ import Testing
66
@MainActor
77
@Suite
88
struct DatePickerWithFieldStyleTests {
9-
#if canImport(AppKit) && !targetEnvironment(macCatalyst)
109
typealias PlatformDatePickerWithFieldStyle = NSDatePicker
11-
#endif
1210

1311
@Test func introspect() async throws {
1412
let date1 = Date(timeIntervalSince1970: 0)
@@ -19,30 +17,22 @@ struct DatePickerWithFieldStyleTests {
1917
VStack {
2018
DatePicker("", selection: .constant(date1))
2119
.datePickerStyle(.field)
22-
#if os(macOS)
2320
.introspect(.datePicker(style: .field), on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy1)
24-
#endif
2521
.cornerRadius(8)
2622

2723
DatePicker("", selection: .constant(date2))
2824
.datePickerStyle(.field)
29-
#if os(macOS)
3025
.introspect(.datePicker(style: .field), on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy2)
31-
#endif
3226
.cornerRadius(8)
3327

3428
DatePicker("", selection: .constant(date3))
3529
.datePickerStyle(.field)
36-
#if os(macOS)
3730
.introspect(.datePicker(style: .field), on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy3)
38-
#endif
3931
}
4032
}
41-
#if canImport(AppKit) && !targetEnvironment(macCatalyst)
4233
#expect(entity1.dateValue == date1)
4334
#expect(entity2.dateValue == date2)
4435
#expect(entity3.dateValue == date3)
45-
#endif
4636
}
4737
}
4838
#endif

Tests/Tests/ViewTypes/DatePickerWithStepperFieldStyleTests.swift

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ import Testing
55

66
@MainActor
77
@Suite struct DatePickerWithStepperFieldStyleTests {
8-
#if canImport(AppKit) && !targetEnvironment(macCatalyst)
98
typealias PlatformDatePickerWithStepperFieldStyle = NSDatePicker
10-
#endif
119

1210
@Test func introspect() async throws {
1311
let date1 = Date(timeIntervalSince1970: 0)
@@ -18,30 +16,22 @@ import Testing
1816
VStack {
1917
DatePicker("", selection: .constant(date1))
2018
.datePickerStyle(.stepperField)
21-
#if os(macOS)
2219
.introspect(.datePicker(style: .stepperField), on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy1)
23-
#endif
2420
.cornerRadius(8)
2521

2622
DatePicker("", selection: .constant(date2))
2723
.datePickerStyle(.stepperField)
28-
#if os(macOS)
2924
.introspect(.datePicker(style: .stepperField), on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy2)
30-
#endif
3125
.cornerRadius(8)
3226

3327
DatePicker("", selection: .constant(date3))
3428
.datePickerStyle(.stepperField)
35-
#if os(macOS)
3629
.introspect(.datePicker(style: .stepperField), on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy3)
37-
#endif
3830
}
3931
}
40-
#if canImport(AppKit) && !targetEnvironment(macCatalyst)
4132
#expect(entity1.dateValue == date1)
4233
#expect(entity2.dateValue == date2)
4334
#expect(entity3.dateValue == date3)
44-
#endif
4535
}
4636
}
4737
#endif

Tests/Tests/ViewTypes/DatePickerWithWheelStyleTests.swift

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ import Testing
66
@MainActor
77
@Suite
88
struct DatePickerWithWheelStyleTests {
9-
#if canImport(UIKit)
109
typealias PlatformDatePickerWithWheelStyle = UIDatePicker
11-
#endif
1210

1311
@Test func introspect() async throws {
1412
let date1 = Date(timeIntervalSince1970: 0)
@@ -19,30 +17,22 @@ struct DatePickerWithWheelStyleTests {
1917
VStack {
2018
DatePicker("", selection: .constant(date1))
2119
.datePickerStyle(.wheel)
22-
#if os(iOS) || os(visionOS)
2320
.introspect(.datePicker(style: .wheel), on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy1)
24-
#endif
2521
.cornerRadius(8)
2622

2723
DatePicker("", selection: .constant(date2))
2824
.datePickerStyle(.wheel)
29-
#if os(iOS) || os(visionOS)
3025
.introspect(.datePicker(style: .wheel), on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy2)
31-
#endif
3226
.cornerRadius(8)
3327

3428
DatePicker("", selection: .constant(date3))
3529
.datePickerStyle(.wheel)
36-
#if os(iOS) || os(visionOS)
3730
.introspect(.datePicker(style: .wheel), on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy3)
38-
#endif
3931
}
4032
}
41-
#if canImport(UIKit)
4233
#expect(entity1.date == date1)
4334
#expect(entity2.date == date2)
4435
#expect(entity3.date == date3)
45-
#endif
4636
}
4737
}
4838
#endif

Tests/Tests/ViewTypes/FullScreenCoverTests.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,11 @@ struct FullScreenCoverTests {
1111
Text("Root")
1212
.fullScreenCover(isPresented: .constant(true)) {
1313
Text("Content")
14-
#if os(iOS) || os(tvOS) || os(visionOS)
1514
.introspect(
1615
.fullScreenCover,
1716
on: .iOS(.v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26),
1817
customize: spy
1918
)
20-
#endif
2119
}
2220
}
2321
}

Tests/Tests/ViewTypes/ListWithBorderedStyleTests.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ import Testing
66
@MainActor
77
@Suite
88
struct ListWithBorderedStyleTests {
9-
#if canImport(AppKit)
109
typealias PlatformListWithBorderedStyle = NSTableView
11-
#endif
1210

1311
@available(macOS 12, *)
1412
@Test func introspect() async throws {
@@ -18,15 +16,11 @@ struct ListWithBorderedStyleTests {
1816
Text("Item 1")
1917
}
2018
.listStyle(.bordered)
21-
#if os(macOS)
2219
.introspect(.list(style: .bordered), on: .macOS(.v12, .v13, .v14, .v15, .v26), customize: spy1)
23-
#endif
2420

2521
List {
2622
Text("Item 1")
27-
#if os(macOS)
2823
.introspect(.list(style: .bordered), on: .macOS(.v12, .v13, .v14, .v15, .v26), scope: .ancestor, customize: spy2)
29-
#endif
3024
}
3125
.listStyle(.bordered)
3226
}

Tests/Tests/ViewTypes/ListWithGroupedStyleTests.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ import Testing
66
@MainActor
77
@Suite
88
struct ListWithGroupedStyleTests {
9-
#if canImport(UIKit)
109
typealias PlatformListWithGroupedStyle = UIScrollView // covers both UITableView and UICollectionView
11-
#endif
1210

1311
@Test func introspect() async throws {
1412
let (entity1, entity2) = try await introspection(of: PlatformListWithGroupedStyle.self) { spy1, spy2 in
@@ -17,17 +15,13 @@ struct ListWithGroupedStyleTests {
1715
Text("Item 1")
1816
}
1917
.listStyle(.grouped)
20-
#if os(iOS) || os(tvOS) || os(visionOS)
2118
.introspect(.list(style: .grouped), on: .iOS(.v13, .v14, .v15), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), customize: spy1)
2219
.introspect(.list(style: .grouped), on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy1)
23-
#endif
2420

2521
List {
2622
Text("Item 1")
27-
#if os(iOS) || os(tvOS) || os(visionOS)
2823
.introspect(.list(style: .grouped), on: .iOS(.v13, .v14, .v15), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), scope: .ancestor, customize: spy2)
2924
.introspect(.list(style: .grouped), on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), scope: .ancestor, customize: spy2)
30-
#endif
3125
}
3226
.listStyle(.grouped)
3327
}

Tests/Tests/ViewTypes/ListWithInsetGroupedStyleTests.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ import Testing
66
@MainActor
77
@Suite
88
struct ListWithInsetGroupedStyleTests {
9-
#if canImport(UIKit)
109
typealias PlatformListWithInsetGroupedStyle = UIScrollView // covers both UITableView and UICollectionView
11-
#endif
1210

1311
@Test func introspect() async throws {
1412
let (entity1, entity2) = try await introspection(of: PlatformListWithInsetGroupedStyle.self) { spy1, spy2 in
@@ -17,17 +15,13 @@ struct ListWithInsetGroupedStyleTests {
1715
Text("Item 1")
1816
}
1917
.listStyle(.insetGrouped)
20-
#if os(iOS) || os(visionOS)
2118
.introspect(.list(style: .insetGrouped), on: .iOS(.v14, .v15), customize: spy1)
2219
.introspect(.list(style: .insetGrouped), on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy1)
23-
#endif
2420

2521
List {
2622
Text("Item 1")
27-
#if os(iOS) || os(visionOS)
2823
.introspect(.list(style: .insetGrouped), on: .iOS(.v14, .v15), scope: .ancestor, customize: spy2)
2924
.introspect(.list(style: .insetGrouped), on: .iOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), scope: .ancestor, customize: spy2)
30-
#endif
3125
}
3226
.listStyle(.insetGrouped)
3327
}

Tests/Tests/ViewTypes/NavigationStackTests.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ import Testing
66
@MainActor
77
@Suite
88
struct NavigationStackTests {
9-
#if canImport(UIKit)
109
typealias PlatformNavigationStack = UINavigationController
11-
#endif
1210

1311
@available(iOS 16, tvOS 16, *)
1412
@Test func introspect() async throws {
@@ -19,9 +17,7 @@ struct NavigationStackTests {
1917
Text("Something")
2018
}
2119
}
22-
#if os(iOS) || os(tvOS) || os(visionOS)
2320
.introspect(.navigationStack, on: .iOS(.v16, .v17, .v18, .v26), .tvOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy)
24-
#endif
2521
}
2622
}
2723

@@ -32,9 +28,7 @@ struct NavigationStackTests {
3228
ZStack {
3329
Color.red
3430
Text("Something")
35-
#if os(iOS) || os(tvOS) || os(visionOS)
3631
.introspect(.navigationStack, on: .iOS(.v16, .v17, .v18, .v26), .tvOS(.v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), scope: .ancestor, customize: spy)
37-
#endif
3832
}
3933
}
4034
}

Tests/Tests/ViewTypes/NavigationViewWithStackStyleTests.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ import Testing
66
@MainActor
77
@Suite
88
struct NavigationViewWithStackStyleTests {
9-
#if canImport(UIKit)
109
typealias PlatformNavigationViewWithStackStyle = UINavigationController
11-
#endif
1210

1311
@Test func introspect() async throws {
1412
try await introspection(of: PlatformNavigationViewWithStackStyle.self) { spy in
@@ -19,9 +17,7 @@ struct NavigationViewWithStackStyleTests {
1917
}
2018
}
2119
.navigationViewStyle(.stack)
22-
#if os(iOS) || os(tvOS) || os(visionOS)
2320
.introspect(.navigationView(style: .stack), on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), customize: spy)
24-
#endif
2521
}
2622
}
2723

@@ -31,9 +27,7 @@ struct NavigationViewWithStackStyleTests {
3127
ZStack {
3228
Color.red
3329
Text("Something")
34-
#if os(iOS) || os(tvOS) || os(visionOS)
3530
.introspect(.navigationView(style: .stack), on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26), scope: .ancestor, customize: spy)
36-
#endif
3731
}
3832
}
3933
.navigationViewStyle(.stack)

0 commit comments

Comments
 (0)