Skip to content

Commit 00ddf7a

Browse files
committed
add type signature disambiguation tests
1 parent 7d3e0c4 commit 00ddf7a

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

Sources/SymbolGraphLinkerTests/LinkResolution.swift

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import FNV1
22
import LexicalPaths
33
import MarkdownAST
4+
import Symbols
45
import Testing
56

67
@_spi(testable)
@@ -164,6 +165,7 @@ struct LinkResolution
164165
])
165166
}
166167
}
168+
167169
// https://forums.swift.org/t/you-must-add-the-tutorials-prefix-to-the-path-really/70016/5
168170
@Test
169171
static func CrossModuleArticles()
@@ -195,4 +197,65 @@ struct LinkResolution
195197
])
196198
}
197199
}
200+
201+
@Test
202+
static func SignatureDisambiguation()
203+
{
204+
var tables:SSGC.Linker.Tables = .init()
205+
206+
for (i, (name, (inputs, output))):(Int, (String, ([String], [String]))) in [
207+
("f(_:)", (["String"], [])),
208+
("f(_:)", (["Int"], [])),
209+
("f(_:)", (["String"], ["Int", "Int"])),
210+
("f(_:)", (["(Int,[Int?])"], ["String"])),
211+
].enumerated()
212+
{
213+
let id:Symbol.Decl = .init(.s, ascii: "\(i)")
214+
tables.packageLinks["ThisModule", .init(["A"], name)].append(.init(
215+
phylum: .func(.instance),
216+
decl: Int32.init(i),
217+
heir: nil,
218+
hash: .init(hashing: "\(id)"),
219+
documented: true,
220+
autograph: .init(inputs: inputs, output: output),
221+
id: id))
222+
}
223+
224+
// Scoped tests
225+
tables.resolving(with: .init(origin: nil,
226+
namespace: nil,
227+
context: .init(id: "ThisModule"),
228+
scope: ["A"]))
229+
{
230+
#expect(nil != $0.outline(
231+
reference: .lexical(ucf: Self._string("f(_:)-((Int,[Int?]))->String"))))
232+
#expect(nil != $0.outline(
233+
reference: .lexical(ucf: Self._string("f(_:)-(String)->(Int,Int)"))))
234+
#expect(nil != $0.outline(
235+
reference: .lexical(ucf: Self._string("f(_:)-(Int)->()"))))
236+
#expect(nil != $0.outline(
237+
reference: .lexical(ucf: Self._string("f(_:)-(String)->()"))))
238+
239+
#expect(nil != $0.outline(
240+
reference: .lexical(ucf: Self._string("A.f(_:)->_"))))
241+
#expect(nil != $0.outline(
242+
reference: .lexical(ucf: Self._string("A.f(_:)->(_,_)"))))
243+
#expect(nil != $0.outline(
244+
reference: .lexical(ucf: Self._string("A.f(_:)-(Int)"))))
245+
#expect(nil != $0.outline(
246+
reference: .lexical(ucf: Self._string("A.f(_:)-(String)->()"))))
247+
248+
#expect($0.outlines() == [
249+
.vertex(3, text: "f(_:)"),
250+
.vertex(2, text: "f(_:)"),
251+
.vertex(1, text: "f(_:)"),
252+
.vertex(0, text: "f(_:)"),
253+
254+
.vertex(3, text: "A f(_:)"),
255+
.vertex(2, text: "A f(_:)"),
256+
.vertex(1, text: "A f(_:)"),
257+
.vertex(0, text: "A f(_:)"),
258+
])
259+
}
260+
}
198261
}

0 commit comments

Comments
 (0)