Skip to content

Commit 5d943f2

Browse files
authored
Remove Test.ID.Selection.testIDs Set property (#116)
This removes the `Test.ID.Selection.testIDs` property whose type is `Set<Test.ID>`, since it's no longer used as of #48
1 parent 0b00668 commit 5d943f2

File tree

2 files changed

+58
-70
lines changed

2 files changed

+58
-70
lines changed

Sources/Testing/Test.ID.Selection.swift

Lines changed: 58 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -27,80 +27,78 @@ extension Test.ID {
2727
/// `contains(_:)` methods.
2828
private var _testIDsGraph = Graph<String, Bool>(value: false)
2929

30-
/// A `Set` representing the test IDs which have been explicitly added.
31-
///
32-
/// May include test IDs that are redundant and overlap with others.
33-
private(set) var testIDs: Set<Test.ID>
34-
3530
/// Initialize an instance of this type with the specified test IDs.
3631
///
3732
/// - Parameters:
3833
/// - testIDs: The test IDs to include in the selection.
3934
init(testIDs: some Collection<Test.ID>) {
40-
self.testIDs = Set(testIDs)
4135
_testIDsGraph = .init(value: false)
42-
for testID in self.testIDs {
36+
for testID in testIDs {
4337
_testIDsGraph.insertValue(true, at: testID.keyPathRepresentation, intermediateValue: false)
4438
}
4539
}
40+
}
41+
}
4642

47-
/// Determine if the selection contains the ID for the specified test.
48-
///
49-
/// - Parameters:
50-
/// - test: The test whose ID should be queried.
51-
///
52-
/// - Returns: Whether or not the selection contains the ID for the
53-
/// specified test.
54-
///
55-
/// A test ID is considered contained in the selection if it has been
56-
/// explicitly added or if it has a descendant or ancestor which has been
57-
/// explicitly added.
58-
@Sendable func contains(_ test: Test) -> Bool {
59-
contains(test.id)
60-
}
43+
// MARK: - Querying membership
6144

62-
/// Determine if the selection contains a specified test ID.
63-
///
64-
/// - Parameters:
65-
/// - testID: The test ID to query.
66-
///
67-
/// - Returns: Whether or not the selection contains the specified test ID.
68-
///
69-
/// A test ID is considered contained in the selection if it has been
70-
/// explicitly added or if it has a descendant or ancestor which has been
71-
/// explicitly added.
72-
@Sendable func contains(_ testID: Test.ID) -> Bool {
73-
contains(testID.keyPathRepresentation)
74-
}
45+
extension Test.ID.Selection {
46+
/// Determine if the selection contains the ID for the specified test.
47+
///
48+
/// - Parameters:
49+
/// - test: The test whose ID should be queried.
50+
///
51+
/// - Returns: Whether or not the selection contains the ID for the
52+
/// specified test.
53+
///
54+
/// A test ID is considered contained in the selection if it has been
55+
/// explicitly added or if it has a descendant or ancestor which has been
56+
/// explicitly added.
57+
@Sendable func contains(_ test: Test) -> Bool {
58+
contains(test.id)
59+
}
7560

76-
/// Determine if the selection contains a test ID with the specified fully-
77-
/// qualified name components.
78-
///
79-
/// - Parameters:
80-
/// - fullyQualifiedNameComponents: The fully-qualified name components of
81-
/// the test ID to query.
82-
///
83-
/// - Returns: Whether or not the selection contains a test ID with the
84-
/// specified fully-qualified name components.
85-
///
86-
/// A test ID is considered contained in the selection if it has been
87-
/// explicitly added or if it has a descendant or ancestor which has been
88-
/// explicitly added.
89-
func contains(_ fullyQualifiedNameComponents: some Collection<String>) -> Bool {
90-
var isContained = false
61+
/// Determine if the selection contains a specified test ID.
62+
///
63+
/// - Parameters:
64+
/// - testID: The test ID to query.
65+
///
66+
/// - Returns: Whether or not the selection contains the specified test ID.
67+
///
68+
/// A test ID is considered contained in the selection if it has been
69+
/// explicitly added or if it has a descendant or ancestor which has been
70+
/// explicitly added.
71+
@Sendable func contains(_ testID: Test.ID) -> Bool {
72+
contains(testID.keyPathRepresentation)
73+
}
9174

92-
for value in _testIDsGraph.takeValues(at: fullyQualifiedNameComponents) {
93-
switch value {
94-
case .some(false):
95-
isContained = true
96-
case .some(true):
97-
return true
98-
case nil:
99-
return false
100-
}
101-
}
75+
/// Determine if the selection contains a test ID with the specified fully-
76+
/// qualified name components.
77+
///
78+
/// - Parameters:
79+
/// - fullyQualifiedNameComponents: The fully-qualified name components of
80+
/// the test ID to query.
81+
///
82+
/// - Returns: Whether or not the selection contains a test ID with the
83+
/// specified fully-qualified name components.
84+
///
85+
/// A test ID is considered contained in the selection if it has been
86+
/// explicitly added or if it has a descendant or ancestor which has been
87+
/// explicitly added.
88+
func contains(_ fullyQualifiedNameComponents: some Collection<String>) -> Bool {
89+
var isContained = false
10290

103-
return isContained
91+
for value in _testIDsGraph.takeValues(at: fullyQualifiedNameComponents) {
92+
switch value {
93+
case .some(false):
94+
isContained = true
95+
case .some(true):
96+
return true
97+
case nil:
98+
return false
99+
}
104100
}
101+
102+
return isContained
105103
}
106104
}

Tests/TestingTests/Test.ID.SelectionTests.swift

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,4 @@ struct Test_ID_SelectionTests {
9595
#expect(selection.contains(["A", "X", "Y"]))
9696
#expect(!selection.contains(["X"]))
9797
}
98-
99-
@Test("Test.ID.Selection.testIDs property")
100-
func testIDsSet() {
101-
let testIDs: Set<Test.ID> = [
102-
Test.ID(["A"]),
103-
Test.ID(["A", "B"]),
104-
]
105-
let selection = Test.ID.Selection(testIDs: testIDs)
106-
#expect(selection.testIDs == testIDs)
107-
}
10898
}

0 commit comments

Comments
 (0)