Skip to content

Commit 8777ba0

Browse files
committed
Test coverage for symbol graphs containing the "extended" module attribute.
Existing tests still pass as-is because symbol graphs without the `extended` attribute use the existing behavior, to read the extended module from the file name.
1 parent 28bdfff commit 8777ba0

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

Tests/SymbolKitTests/UnifiedGraph/GraphCollectorTests.swift

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,26 @@ class GraphCollectorTests: XCTestCase {
127127
mixins: [:])
128128
],
129129
relationships: [])
130+
131+
var (extensionName, extensionIsMain) = GraphCollector.moduleNameFor(a_At_B, at: .init(fileURLWithPath: "[email protected]"))
132+
XCTAssertFalse(extensionIsMain)
133+
XCTAssertEqual("B", extensionName)
134+
135+
// "A@B" style graph, with extension of B in module A, using shortened name scheme.
136+
let a_At_B_Shortened = SymbolGraph(metadata: .init(formatVersion: .init(major: 1, minor: 0, patch: 0), generator: "unit-test"),
137+
module: .init(name: "A", platform: .init(), extended: "B"),
138+
symbols: [
139+
.init(identifier: .init(precise: "s:BBAatB", interfaceLanguage: "swift"),
140+
names: .init(title: "AatB", navigator: nil, subHeading: nil, prose: nil),
141+
pathComponents: ["B", "AatB"],
142+
docComment: nil,
143+
accessLevel: .init(rawValue: "public"),
144+
kind: .init(parsedIdentifier: .class, displayName: "Class"),
145+
mixins: [:])
146+
],
147+
relationships: [])
130148

131-
let (extensionName, extensionIsMain) = GraphCollector.moduleNameFor(a_At_B, at: .init(fileURLWithPath: "A@B.symbols.json"))
149+
(extensionName, extensionIsMain) = GraphCollector.moduleNameFor(a_At_B_Shortened, at: .init(fileURLWithPath: "ABCDEF123456.symbols.json"))
132150
XCTAssertFalse(extensionIsMain)
133151
XCTAssertEqual("B", extensionName)
134152

@@ -186,5 +204,12 @@ class GraphCollectorTests: XCTestCase {
186204
let (extendedB, extendedBIsMain) = GraphCollector.moduleNameFor(a_At_B, at: .init(fileURLWithPath: "[email protected]"))
187205
XCTAssertFalse(extendedBIsMain)
188206
XCTAssertEqual("B", extendedB)
207+
208+
// "A@B" style graph, with extension of B in module A, using shortened name scheme.
209+
var a_At_B_ShortenedFileName = a_At_B
210+
a_At_B_ShortenedFileName.module.extended = "B"
211+
let (extendedBShortForm, extendedBIsMainShortForm) = GraphCollector.moduleNameFor(a_At_B, at: .init(fileURLWithPath: "[email protected]"))
212+
XCTAssertFalse(extendedBIsMainShortForm)
213+
XCTAssertEqual("B", extendedBShortForm)
189214
}
190215
}

0 commit comments

Comments
 (0)