1
1
/*
2
2
This source file is part of the Swift.org open source project
3
3
4
- Copyright (c) 2024 Apple Inc. and the Swift project authors
4
+ Copyright (c) 2024-2025 Apple Inc. and the Swift project authors
5
5
Licensed under Apache License v2.0 with Runtime Library Exception
6
6
7
7
See https://swift.org/LICENSE.txt for license information
@@ -45,6 +45,7 @@ class SymbolAvailabilityTests: XCTestCase {
45
45
private func renderNodeAvailability(
46
46
defaultAvailability: [ DefaultAvailability . ModuleAvailability ] = [ ] ,
47
47
symbolGraphOperatingSystemPlatformName: String ,
48
+ symbolGraphEnvironmentName: String ? = nil ,
48
49
symbols: [ SymbolGraph . Symbol ] ,
49
50
symbolName: String
50
51
) throws -> [ AvailabilityRenderItem ] {
@@ -56,7 +57,7 @@ class SymbolAvailabilityTests: XCTestCase {
56
57
] ) ,
57
58
JSONFile ( name: " ModuleName.symbols.json " , content: makeSymbolGraph (
58
59
moduleName: " ModuleName " ,
59
- platform: SymbolGraph . Platform ( architecture: nil , vendor: nil , operatingSystem: SymbolGraph . OperatingSystem ( name: symbolGraphOperatingSystemPlatformName) , environment: nil ) ,
60
+ platform: SymbolGraph . Platform ( architecture: nil , vendor: nil , operatingSystem: SymbolGraph . OperatingSystem ( name: symbolGraphOperatingSystemPlatformName) , environment: symbolGraphEnvironmentName ) ,
60
61
symbols: symbols,
61
62
relationships: [ ]
62
63
) ) ,
@@ -71,7 +72,7 @@ class SymbolAvailabilityTests: XCTestCase {
71
72
72
73
func testSymbolGraphSymbolWithoutDeprecatedVersionAndIntroducedVersion( ) throws {
73
74
74
- let availability = try renderNodeAvailability (
75
+ var availability = try renderNodeAvailability (
75
76
defaultAvailability: [ ] ,
76
77
symbolGraphOperatingSystemPlatformName: " ios " ,
77
78
symbols: [
@@ -91,6 +92,34 @@ class SymbolAvailabilityTests: XCTestCase {
91
92
" iPadOS <nil> - 1.2.3 " ,
92
93
" Mac Catalyst <nil> - 1.2.3 " ,
93
94
] )
95
+
96
+ availability = try renderNodeAvailability (
97
+ defaultAvailability: [
98
+ DefaultAvailability . ModuleAvailability ( platformName: PlatformName ( operatingSystemName: " iOS " ) , platformVersion: " 1.2.3 " )
99
+ ] ,
100
+ symbolGraphOperatingSystemPlatformName: " ios " ,
101
+ symbolGraphEnvironmentName: " macabi " ,
102
+ symbols: [
103
+ makeSymbol (
104
+ id: " platform-1-symbol " ,
105
+ kind: . class,
106
+ pathComponents: [ " SymbolName " ] ,
107
+ availability: [
108
+ makeAvailabilityItem ( domainName: " iOS " , deprecated: SymbolGraph . SemanticVersion ( string: " 1.2.3 " ) ) ,
109
+ makeAvailabilityItem ( domainName: " visionOS " , deprecated: SymbolGraph . SemanticVersion ( string: " 1.0.0 " ) )
110
+ ]
111
+ )
112
+ ] ,
113
+ symbolName: " SymbolName "
114
+ )
115
+
116
+ XCTAssertEqual ( availability. map { " \( $0. name ?? " <nil> " ) \( $0. introduced ?? " <nil> " ) - \( $0. deprecated ?? " <nil> " ) " } , [
117
+ // The default availability for iOS shouldnt be copied to visionOS.
118
+ " iOS 1.2.3 - 1.2.3 " ,
119
+ " iPadOS 1.2.3 - <nil> " ,
120
+ " Mac Catalyst 1.2.3 - 1.2.3 " ,
121
+ " visionOS <nil> - 1.0 " ,
122
+ ] )
94
123
}
95
124
96
125
func testSymbolGraphSymbolWithObsoleteVersion( ) throws {
0 commit comments