@@ -28,36 +28,36 @@ enum TestUtils {
2828}
2929#endif
3030
31- func XCTAssertViewIntrospection< V : View , PV : AnyObject > (
32- of type: PV . Type ,
33- @ViewBuilder view: ( Spies < PV > ) -> V ,
34- extraAssertions: ( [ PV ] ) -> Void = { _ in } ,
31+ func XCTAssertViewIntrospection< Entity : AnyObject > (
32+ of type: Entity . Type ,
33+ @ViewBuilder view: ( Spies < Entity > ) -> some View ,
34+ extraAssertions: ( [ Entity ] ) -> Void = { _ in } ,
3535 file: StaticString = #file,
3636 line: UInt = #line
3737) {
38- let spies = Spies < PV > ( )
38+ let spies = Spies < Entity > ( )
3939 let view = view ( spies)
4040 TestUtils . present ( view: view)
4141 XCTWaiter ( delegate: spies) . wait ( for: spies. expectations. values. map ( \. 0 ) , timeout: 3 )
42- extraAssertions ( spies. objects . sorted ( by: { $0. key < $1. key } ) . map ( \. value) )
42+ extraAssertions ( spies. entities . sorted ( by: { $0. key < $1. key } ) . map ( \. value) )
4343}
4444
45- final class Spies < PV : AnyObject > : NSObject , XCTWaiterDelegate {
46- private( set) var objects : [ Int : PV ] = [ : ]
45+ final class Spies < Entity : AnyObject > : NSObject , XCTWaiterDelegate {
46+ private( set) var entities : [ Int : Entity ] = [ : ]
4747 private( set) var expectations : [ ObjectIdentifier : ( XCTestExpectation , StaticString , UInt ) ] = [ : ]
4848
4949 subscript(
5050 number: Int ,
5151 file: StaticString = #file,
5252 line: UInt = #line
53- ) -> ( PV ) -> Void {
53+ ) -> ( Entity ) -> Void {
5454 let expectation = XCTestExpectation ( )
5555 expectations [ ObjectIdentifier ( expectation) ] = ( expectation, file, line)
5656 return { [ self ] in
57- if let object = objects [ number] {
58- XCTAssert ( object === $0, " Found view was overriden by another view " , file: file, line: line)
57+ if let entity = entities [ number] {
58+ XCTAssert ( entity === $0, " Found view was overriden by another view " , file: file, line: line)
5959 }
60- objects [ number] = $0
60+ entities [ number] = $0
6161 expectation. fulfill ( )
6262 }
6363 }
@@ -97,12 +97,10 @@ final class Spies<PV: AnyObject>: NSObject, XCTWaiterDelegate {
9797
9898extension Collection {
9999 subscript( safe index: Index , file: StaticString = #file, line: UInt = #line) -> Element ? {
100- get {
101- guard indices. contains ( index) else {
102- XCTFail ( " Index \( index) is out of bounds " , file: file, line: line)
103- return nil
104- }
105- return self [ index]
100+ guard indices. contains ( index) else {
101+ XCTFail ( " Index \( index) is out of bounds " , file: file, line: line)
102+ return nil
106103 }
104+ return self [ index]
107105 }
108106}
0 commit comments