|
1 | 1 | import FNV1
|
2 | 2 | import LexicalPaths
|
3 | 3 | import MarkdownAST
|
| 4 | +import Symbols |
4 | 5 | import Testing
|
5 | 6 |
|
6 | 7 | @_spi(testable)
|
@@ -164,6 +165,7 @@ struct LinkResolution
|
164 | 165 | ])
|
165 | 166 | }
|
166 | 167 | }
|
| 168 | + |
167 | 169 | // https://forums.swift.org/t/you-must-add-the-tutorials-prefix-to-the-path-really/70016/5
|
168 | 170 | @Test
|
169 | 171 | static func CrossModuleArticles()
|
@@ -195,4 +197,65 @@ struct LinkResolution
|
195 | 197 | ])
|
196 | 198 | }
|
197 | 199 | }
|
| 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 | + } |
198 | 261 | }
|
0 commit comments