File tree Expand file tree Collapse file tree
Tests/OpenSwiftUITests/View Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ //
2+ // IdentityLinkTests.swift
3+ // OpenSwiftUITests
4+
5+ import OpenAttributeGraphShims
6+ #if OPENSWIFTUI_ENABLE_PRIVATE_IMPORTS
7+ @_private ( sourceFile: " IdentityLink.swift " )
8+ #endif
9+ @testable import OpenSwiftUI
10+ @_spi ( ForOpenSwiftUIOnly) import OpenSwiftUICore
11+ import Testing
12+
13+ @MainActor
14+ @Suite
15+ struct IdentityLinkTests {
16+ @Test
17+ func seed( ) {
18+ let identities = ( 0 ..< 64 ) . map { _ in ViewIdentity ( ) }
19+ #expect( Set ( identities) . count == 64 )
20+ #expect( !identities. contains ( . invalid) )
21+ }
22+
23+ #if OPENSWIFTUI_ENABLE_PRIVATE_IMPORTS
24+ @Test
25+ func overflow( ) {
26+ ViewIdentity . nextSeed = UInt32 . max
27+ let id1 = ViewIdentity ( )
28+ #expect( id1. seed == UInt32 . max)
29+ let id2 = ViewIdentity ( )
30+ #expect( id2 != . invalid)
31+ #expect( id2. seed == 1 )
32+ }
33+ #endif
34+
35+ #if !os(iOS) && !os(visionOS)
36+ @Test
37+ func readingBeforeInstallationFails( ) async throws {
38+ let result = try await #require(
39+ processExitsWith: . failure,
40+ observing: [ \. standardErrorContent]
41+ ) {
42+ _ = IdentityLink ( ) . wrappedValue
43+ }
44+ #if DEBUG
45+ let diagnostic = String ( decoding: result. standardErrorContent, as: UTF8 . self)
46+ #expect( diagnostic. contains ( " Reading IdentityLink outside View.body " ) )
47+ #else
48+ _ = result
49+ #endif
50+ }
51+ #endif
52+ }
You can’t perform that action at this time.
0 commit comments