Skip to content

Commit e973a96

Browse files
authored
(116534829) Remove FOUNDATION_FRAMEWORK restriction on macOS Predicate tests
* Remove FOUNDATION_FRAMEWORK restriction on Predicate tests * Add runtime availability check to PredicateTests
1 parent 3d52b25 commit e973a96

File tree

2 files changed

+31
-11
lines changed

2 files changed

+31
-11
lines changed

Tests/FoundationEssentialsTests/PredicateTests.swift

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@
1414
import TestSupport
1515
#endif
1616

17-
// Predicate does not back-deploy to older Darwin versions
18-
#if FOUNDATION_FRAMEWORK || os(Linux) || os(Windows)
19-
20-
@available(macOS 14, iOS 17, tvOS 17, watchOS 10, *)
2117
final class PredicateTests: XCTestCase {
2218

19+
override func setUp() async throws {
20+
guard #available(macOS 14, iOS 17, tvOS 17, watchOS 10, *) else {
21+
throw XCTSkip("This test is not available on this OS version")
22+
}
23+
}
24+
2325
struct Object {
2426
var a: Int
2527
var b: String
@@ -35,6 +37,7 @@ final class PredicateTests: XCTestCase {
3537
var a: Bool
3638
}
3739

40+
@available(macOS 14, iOS 17, tvOS 17, watchOS 10, *)
3841
func testBasic() throws {
3942
let compareTo = 2
4043
let predicate = Predicate<Object> {
@@ -53,6 +56,7 @@ final class PredicateTests: XCTestCase {
5356
try XCTAssertTrue(predicate.evaluate(Object(a: 2, b: "", c: 0, d: 0, e: "c", f: true, g: [])))
5457
}
5558

59+
@available(macOS 14, iOS 17, tvOS 17, watchOS 10, *)
5660
func testBasicMacro() throws {
5761
#if compiler(<5.9) || os(Windows)
5862
throw XCTSkip("Macros are not supported on this platform")
@@ -66,6 +70,7 @@ final class PredicateTests: XCTestCase {
6670
#endif
6771
}
6872

73+
@available(macOS 14, iOS 17, tvOS 17, watchOS 10, *)
6974
func testVariadic() throws {
7075
let predicate = Predicate<Object, Int> {
7176
// $0.a == $1 + 1
@@ -88,6 +93,7 @@ final class PredicateTests: XCTestCase {
8893
XCTAssert(try predicate.evaluate(Object(a: 3, b: "", c: 0, d: 0, e: "c", f: true, g: []), 2))
8994
}
9095

96+
@available(macOS 14, iOS 17, tvOS 17, watchOS 10, *)
9197
func testArithmetic() throws {
9298
let predicate = Predicate<Object> {
9399
// $0.a + 2 == 4
@@ -110,6 +116,7 @@ final class PredicateTests: XCTestCase {
110116
XCTAssert(try predicate.evaluate(Object(a: 2, b: "", c: 0, d: 0, e: "c", f: true, g: [])))
111117
}
112118

119+
@available(macOS 14, iOS 17, tvOS 17, watchOS 10, *)
113120
func testDivision() throws {
114121
let predicate = Predicate<Object> {
115122
// $0.a / 2 == 3
@@ -150,6 +157,7 @@ final class PredicateTests: XCTestCase {
150157
XCTAssert(try predicate2.evaluate(Object(a: 2, b: "", c: 6.0, d: 0, e: "c", f: true, g: [])))
151158
}
152159

160+
@available(macOS 14, iOS 17, tvOS 17, watchOS 10, *)
153161
func testBuildDivision() throws {
154162
let predicate = Predicate<Object> {
155163
PredicateExpressions.build_Equal(
@@ -169,6 +177,7 @@ final class PredicateTests: XCTestCase {
169177
XCTAssert(try predicate.evaluate(Object(a: 6, b: "", c: 0, d: 0, e: "c", f: true, g: [])))
170178
}
171179

180+
@available(macOS 14, iOS 17, tvOS 17, watchOS 10, *)
172181
func testUnaryMinus() throws {
173182
let predicate = Predicate<Object> {
174183
// -$0.a == 17
@@ -189,6 +198,7 @@ final class PredicateTests: XCTestCase {
189198
XCTAssert(try predicate.evaluate(Object(a: -17, b: "", c: 0, d: 0, e: "c", f: true, g: [])))
190199
}
191200

201+
@available(macOS 14, iOS 17, tvOS 17, watchOS 10, *)
192202
func testCount() throws {
193203
let predicate = Predicate<Object> {
194204
// $0.g.count == 5
@@ -208,6 +218,7 @@ final class PredicateTests: XCTestCase {
208218
XCTAssert(try predicate.evaluate(Object(a: 0, b: "", c: 0, d: 0, e: "c", f: true, g: [2, 3, 5, 7, 11])))
209219
}
210220

221+
@available(macOS 14, iOS 17, tvOS 17, watchOS 10, *)
211222
func testFilter() throws {
212223
let predicate = Predicate<Object> { object in
213224
/*object.g.filter {
@@ -246,6 +257,7 @@ final class PredicateTests: XCTestCase {
246257
XCTAssert(try predicate.evaluate(Object(a: 0, b: "", c: 0.0, d: 17, e: "c", f: true, g: [3, 5, 7, 11, 13, 17, 19])))
247258
}
248259

260+
@available(macOS 14, iOS 17, tvOS 17, watchOS 10, *)
249261
func testContains() throws {
250262
let predicate = Predicate<Object> {
251263
// $0.g.contains($0.a)
@@ -267,6 +279,7 @@ final class PredicateTests: XCTestCase {
267279
XCTAssert(try predicate.evaluate(Object(a: 13, b: "", c: 0.0, d: 0, e: "c", f: true, g: [2, 3, 5, 11, 13, 17])))
268280
}
269281

282+
@available(macOS 14, iOS 17, tvOS 17, watchOS 10, *)
270283
func testContainsWhere() throws {
271284
let predicate = Predicate<Object> { object in
272285
// object.g.contains { $0 % object.a == 0 }
@@ -298,6 +311,7 @@ final class PredicateTests: XCTestCase {
298311
XCTAssert(try predicate.evaluate(Object(a: 2, b: "", c: 0.0, d: 0, e: "c", f: true, g: [3, 5, 7, 2, 11, 13])))
299312
}
300313

314+
@available(macOS 14, iOS 17, tvOS 17, watchOS 10, *)
301315
func testAllSatisfy() throws {
302316
let predicate = Predicate<Object> { object in
303317
// object.g.allSatisfy { $0 % object.d != 0 }
@@ -329,6 +343,7 @@ final class PredicateTests: XCTestCase {
329343
XCTAssert(try predicate.evaluate(Object(a: 0, b: "", c: 0.0, d: 2, e: "c", f: true, g: [3, 5, 7, 11, 13, 17, 19])))
330344
}
331345

346+
@available(macOS 14, iOS 17, tvOS 17, watchOS 10, *)
332347
func testOptional() throws {
333348
struct Wrapper<T> {
334349
let wrapped: T?
@@ -401,6 +416,7 @@ final class PredicateTests: XCTestCase {
401416
XCTAssertTrue(try predicate3.evaluate(Wrapper(wrapped: nil)))
402417
}
403418

419+
@available(macOS 14, iOS 17, tvOS 17, watchOS 10, *)
404420
func testConditional() throws {
405421
let predicate = Predicate<Bool, String, String> {
406422
// ($0 ? $1 : $2) == "if branch"
@@ -418,6 +434,7 @@ final class PredicateTests: XCTestCase {
418434
XCTAssert(try predicate.evaluate(true, "if branch", "else branch"))
419435
}
420436

437+
@available(macOS 14, iOS 17, tvOS 17, watchOS 10, *)
421438
func testClosedRange() throws {
422439
let predicate = Predicate<Object> {
423440
// (3...5).contains($0.a)
@@ -462,6 +479,7 @@ final class PredicateTests: XCTestCase {
462479
XCTAssert(try predicate2.evaluate(Object(a: 3, b: "", c: 0.0, d: 5, e: "c", f: true, g: [])))
463480
}
464481

482+
@available(macOS 14, iOS 17, tvOS 17, watchOS 10, *)
465483
func testRange() throws {
466484
let predicate = Predicate<Object> {
467485
// (3..<5).contains($0.a)
@@ -507,6 +525,7 @@ final class PredicateTests: XCTestCase {
507525
XCTAssert(try predicate2.evaluate(Object(a: 3, b: "", c: 0.0, d: 5, e: "c", f: true, g: [])))
508526
}
509527

528+
@available(macOS 14, iOS 17, tvOS 17, watchOS 10, *)
510529
func testRangeContains() throws {
511530
let date = Date.distantPast
512531
let predicate = Predicate<Object> {
@@ -526,6 +545,7 @@ final class PredicateTests: XCTestCase {
526545
XCTAssertFalse(try predicate.evaluate(Object(a: 3, b: "", c: 0.0, d: 5, e: "c", f: true, g: [])))
527546
}
528547

548+
@available(macOS 14, iOS 17, tvOS 17, watchOS 10, *)
529549
func testTypes() throws {
530550
let predicate = Predicate<Object> {
531551
// ($0.a as? Int).flatMap { $0 == 3 } ?? false
@@ -568,6 +588,7 @@ final class PredicateTests: XCTestCase {
568588
XCTAssert(try predicate2.evaluate(Object(a: 3, b: "", c: 0.0, d: 5, e: "c", f: true, g: [])))
569589
}
570590

591+
@available(macOS 14, iOS 17, tvOS 17, watchOS 10, *)
571592
func testSubscripts() throws {
572593
var predicate = Predicate<Object> {
573594
// $0.g[0] == 0
@@ -609,6 +630,7 @@ final class PredicateTests: XCTestCase {
609630
XCTAssertThrowsError(try predicate.evaluate(Object(a: 3, b: "", c: 0.0, d: 0, e: "c", f: true, g: [])))
610631
}
611632

633+
@available(macOS 14, iOS 17, tvOS 17, watchOS 10, *)
612634
func testLazyDefaultValueSubscript() throws {
613635
struct Foo : Codable, Sendable {
614636
static var num = 1
@@ -637,6 +659,7 @@ final class PredicateTests: XCTestCase {
637659
XCTAssertEqual(Foo.num, 1)
638660
}
639661

662+
@available(macOS 14, iOS 17, tvOS 17, watchOS 10, *)
640663
func testStaticValues() throws {
641664
func assertPredicate<T>(_ pred: Predicate<T>, value: T, expected: Bool) throws {
642665
XCTAssertEqual(try pred.evaluate(value), expected)
@@ -646,6 +669,7 @@ final class PredicateTests: XCTestCase {
646669
try assertPredicate(.false, value: "Hello", expected: false)
647670
}
648671

672+
@available(macOS 14, iOS 17, tvOS 17, watchOS 10, *)
649673
func testMaxMin() throws {
650674
var predicate = Predicate<Object> {
651675
// $0.g.max() == 2
@@ -680,6 +704,7 @@ final class PredicateTests: XCTestCase {
680704

681705
#if FOUNDATION_FRAMEWORK
682706

707+
@available(macOS 14, iOS 17, tvOS 17, watchOS 10, *)
683708
func testCaseInsensitiveCompare() throws {
684709
let equal = ComparisonResult.orderedSame
685710
let predicate = Predicate<Object> {
@@ -701,6 +726,7 @@ final class PredicateTests: XCTestCase {
701726

702727
#endif
703728

729+
@available(macOS 14, iOS 17, tvOS 17, watchOS 10, *)
704730
func testBuildDynamically() throws {
705731
func _build(_ equal: Bool) -> Predicate<Int> {
706732
Predicate<Int> {
@@ -722,6 +748,7 @@ final class PredicateTests: XCTestCase {
722748
XCTAssertFalse(try _build(false).evaluate(1))
723749
}
724750

751+
@available(macOS 14, iOS 17, tvOS 17, watchOS 10, *)
725752
func testResilientKeyPaths() {
726753
// Local, non-resilient type
727754
struct Foo {
@@ -754,5 +781,3 @@ final class PredicateTests: XCTestCase {
754781
}
755782
}
756783
}
757-
758-
#endif

Tests/FoundationInternationalizationTests/PredicateInternationalizationTests.swift

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414
import TestSupport
1515
#endif
1616

17-
// Predicate does not back-deploy to older Darwin versions
18-
#if FOUNDATION_FRAMEWORK || os(Linux) || os(Windows)
19-
2017
@available(macOS 14, iOS 17, tvOS 17, watchOS 10, *)
2118
final class PredicateInternationalizationTests: XCTestCase {
2219

@@ -68,5 +65,3 @@ final class PredicateInternationalizationTests: XCTestCase {
6865
#endif
6966

7067
}
71-
72-
#endif

0 commit comments

Comments
 (0)