11/*
22 This source file is part of the Swift.org open source project
33
4- Copyright (c) 2024 Apple Inc. and the Swift project authors
4+ Copyright (c) 2024-2025 Apple Inc. and the Swift project authors
55 Licensed under Apache License v2.0 with Runtime Library Exception
66
77 See https://swift.org/LICENSE.txt for license information
@@ -45,6 +45,7 @@ class SymbolAvailabilityTests: XCTestCase {
4545 private func renderNodeAvailability(
4646 defaultAvailability: [ DefaultAvailability . ModuleAvailability ] = [ ] ,
4747 symbolGraphOperatingSystemPlatformName: String ,
48+ symbolGraphEnvironmentName: String ? = nil ,
4849 symbols: [ SymbolGraph . Symbol ] ,
4950 symbolName: String
5051 ) throws -> [ AvailabilityRenderItem ] {
@@ -56,7 +57,7 @@ class SymbolAvailabilityTests: XCTestCase {
5657 ] ) ,
5758 JSONFile ( name: " ModuleName.symbols.json " , content: makeSymbolGraph (
5859 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 ) ,
6061 symbols: symbols,
6162 relationships: [ ]
6263 ) ) ,
@@ -71,7 +72,7 @@ class SymbolAvailabilityTests: XCTestCase {
7172
7273 func testSymbolGraphSymbolWithoutDeprecatedVersionAndIntroducedVersion( ) throws {
7374
74- let availability = try renderNodeAvailability (
75+ var availability = try renderNodeAvailability (
7576 defaultAvailability: [ ] ,
7677 symbolGraphOperatingSystemPlatformName: " ios " ,
7778 symbols: [
@@ -91,6 +92,34 @@ class SymbolAvailabilityTests: XCTestCase {
9192 " iPadOS <nil> - 1.2.3 " ,
9293 " Mac Catalyst <nil> - 1.2.3 " ,
9394 ] )
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+ ] )
94123 }
95124
96125 func testSymbolGraphSymbolWithObsoleteVersion( ) throws {
0 commit comments