From 39338c0520bf45a15ac0d55f30d213f1a085262a Mon Sep 17 00:00:00 2001 From: Noah Kamara Date: Thu, 24 Oct 2024 23:52:44 +0200 Subject: [PATCH] chore: update tests to swift testing --- .../ArithmeticTests.swift | 15 ++++++------- Tests/CompoundPredicateTests/BasicTests.swift | 22 +++---------------- .../BooleanLogicTests.swift | 4 ++-- .../CompoundPredicateTests/CastingTests.swift | 4 ++-- .../ComparisonTests.swift | 4 ++-- .../ConditionalTests.swift | 6 ++--- .../OptionalTests.swift | 4 ++-- Tests/CompoundPredicateTests/RangeTests.swift | 5 ++--- .../SequenceOperationTests.swift | 4 ++-- .../StringComparisonTests.swift | 4 ++-- .../SubscriptAndMemberTests.swift | 4 ++-- .../Utility/Utility.swift | 13 +++++++++-- 12 files changed, 40 insertions(+), 49 deletions(-) diff --git a/Tests/CompoundPredicateTests/ArithmeticTests.swift b/Tests/CompoundPredicateTests/ArithmeticTests.swift index 89ff1c0..adac864 100644 --- a/Tests/CompoundPredicateTests/ArithmeticTests.swift +++ b/Tests/CompoundPredicateTests/ArithmeticTests.swift @@ -1,7 +1,6 @@ -import XCTesting +import Testing +import Foundation - -@XCTesting @Suite /// Tests for Arithmetic (+, -, \*, /, %) and Unary Minus (-) Operators struct ArithmeticTests { @@ -118,8 +117,8 @@ struct ArithmeticTests { } } -extension PredicateExpressions.Variable: Equatable { - public static func == (lhs: Self, rhs: Self) -> Bool { - lhs.key == rhs.key - } -} +//extension PredicateExpressions.Variable: Equatable { +// public static func == (lhs: Self, rhs: Self) -> Bool { +// lhs.key == rhs.key +// } +//} diff --git a/Tests/CompoundPredicateTests/BasicTests.swift b/Tests/CompoundPredicateTests/BasicTests.swift index e4816f7..76ff20e 100644 --- a/Tests/CompoundPredicateTests/BasicTests.swift +++ b/Tests/CompoundPredicateTests/BasicTests.swift @@ -1,7 +1,7 @@ -import XCTesting +import Testing @testable import CompoundPredicate +import Foundation -@XCTesting @Suite struct BasicTests { @Test @@ -92,23 +92,7 @@ struct BasicTests { let lhs = Predicate({ CustomPredicate(variable: $0) }) let rhs = Predicate({ CustomPredicate(variable: $0) }) - await confirmation(expectedCount: 2) { confirm in - NotificationCenter.default.addObserver( - forName: .foundationExtensionsRuntimeWarning, - object: nil, - queue: .main - ) { notification in - let runtimeWarnMsg = try? #require(notification.userInfo?["message"] as? String) - - guard let runtimeWarnMsg else { return } - - #expect(runtimeWarnMsg.contains("\(CustomPredicate.self) is not a supported Predicate.")) - - print("CALLED") - confirm() - } - - XCTExpectFailure("Cannot combine unsupported Predicate", strict: true) + withKnownIssue { _ = [lhs, rhs].disjunction() } } diff --git a/Tests/CompoundPredicateTests/BooleanLogicTests.swift b/Tests/CompoundPredicateTests/BooleanLogicTests.swift index 512447f..cc56fbe 100644 --- a/Tests/CompoundPredicateTests/BooleanLogicTests.swift +++ b/Tests/CompoundPredicateTests/BooleanLogicTests.swift @@ -1,7 +1,7 @@ -import XCTesting +import Testing import CompoundPredicate +import Foundation -@XCTesting @Suite struct BooleanLogicTests { @Test diff --git a/Tests/CompoundPredicateTests/CastingTests.swift b/Tests/CompoundPredicateTests/CastingTests.swift index bd0ae2d..650d4f0 100644 --- a/Tests/CompoundPredicateTests/CastingTests.swift +++ b/Tests/CompoundPredicateTests/CastingTests.swift @@ -1,7 +1,7 @@ -import XCTesting +import Testing import CompoundPredicate +import Foundation -@XCTesting @Suite struct CastingTests { @Test diff --git a/Tests/CompoundPredicateTests/ComparisonTests.swift b/Tests/CompoundPredicateTests/ComparisonTests.swift index 0388962..fe06cc6 100644 --- a/Tests/CompoundPredicateTests/ComparisonTests.swift +++ b/Tests/CompoundPredicateTests/ComparisonTests.swift @@ -1,7 +1,7 @@ -import XCTesting +import Testing +import Foundation -@XCTesting @Suite struct ComparisonTests { @Test(arguments: [PredicateExpressions.ComparisonOperator.greaterThan, .greaterThanOrEqual, .lessThan, .lessThanOrEqual]) diff --git a/Tests/CompoundPredicateTests/ConditionalTests.swift b/Tests/CompoundPredicateTests/ConditionalTests.swift index 8297269..0558147 100644 --- a/Tests/CompoundPredicateTests/ConditionalTests.swift +++ b/Tests/CompoundPredicateTests/ConditionalTests.swift @@ -1,7 +1,6 @@ -import XCTesting +import Testing +import Foundation - -@XCTesting @Suite struct ConditionalLogicTests { @Test @@ -31,3 +30,4 @@ struct ConditionalLogicTests { #expect(testReplaced.test == replacement) } } + diff --git a/Tests/CompoundPredicateTests/OptionalTests.swift b/Tests/CompoundPredicateTests/OptionalTests.swift index 2b5349b..eb9b7e9 100644 --- a/Tests/CompoundPredicateTests/OptionalTests.swift +++ b/Tests/CompoundPredicateTests/OptionalTests.swift @@ -1,7 +1,7 @@ -import XCTesting +import Testing import CompoundPredicate +import Foundation -@XCTesting @Suite struct OptionalTests { @Test diff --git a/Tests/CompoundPredicateTests/RangeTests.swift b/Tests/CompoundPredicateTests/RangeTests.swift index 464e9c1..71072f2 100644 --- a/Tests/CompoundPredicateTests/RangeTests.swift +++ b/Tests/CompoundPredicateTests/RangeTests.swift @@ -1,7 +1,6 @@ -import XCTesting +import Testing +import Foundation - -@XCTesting @Suite struct RangeTests { @Test diff --git a/Tests/CompoundPredicateTests/SequenceOperationTests.swift b/Tests/CompoundPredicateTests/SequenceOperationTests.swift index 448a5f6..6ce2cc6 100644 --- a/Tests/CompoundPredicateTests/SequenceOperationTests.swift +++ b/Tests/CompoundPredicateTests/SequenceOperationTests.swift @@ -1,7 +1,7 @@ -import XCTesting +import Testing import CompoundPredicate +import Foundation -@XCTesting @Suite struct SequenceOperationTests { @Test diff --git a/Tests/CompoundPredicateTests/StringComparisonTests.swift b/Tests/CompoundPredicateTests/StringComparisonTests.swift index 158782d..a5eedc4 100644 --- a/Tests/CompoundPredicateTests/StringComparisonTests.swift +++ b/Tests/CompoundPredicateTests/StringComparisonTests.swift @@ -1,7 +1,7 @@ -import XCTesting +import Testing import CompoundPredicate +import Foundation -@XCTesting @Suite struct StringComparisonTests { @Test diff --git a/Tests/CompoundPredicateTests/SubscriptAndMemberTests.swift b/Tests/CompoundPredicateTests/SubscriptAndMemberTests.swift index 02af679..656af46 100644 --- a/Tests/CompoundPredicateTests/SubscriptAndMemberTests.swift +++ b/Tests/CompoundPredicateTests/SubscriptAndMemberTests.swift @@ -1,7 +1,7 @@ -import XCTesting +import Testing @testable import CompoundPredicate +import Foundation -@XCTesting @Suite struct SubscriptAndMemberTests { @Test diff --git a/Tests/CompoundPredicateTests/Utility/Utility.swift b/Tests/CompoundPredicateTests/Utility/Utility.swift index ef09185..34a7778 100644 --- a/Tests/CompoundPredicateTests/Utility/Utility.swift +++ b/Tests/CompoundPredicateTests/Utility/Utility.swift @@ -1,8 +1,8 @@ import Foundation // MARK: Person -struct Person: PredicateCodableKeyPathProviding { - static var predicateCodableKeyPaths: [String : PartialKeyPath] = [ +struct Person: Sendable, PredicateCodableKeyPathProviding { + static var predicateCodableKeyPaths: [String : any PartialKeyPath & Sendable] = [ "Person.name": \.name, "Person.age": \.age, "Person.isStarred": \.isStarred, @@ -148,3 +148,12 @@ fileprivate struct Unknown: CustomStringConvertible { } } + + + + +extension PredicateExpressions.Variable: @retroactive Equatable { + public static func == (lhs: Self, rhs: Self) -> Bool { + lhs.key == rhs.key + } +}