Skip to content

Commit cf59e07

Browse files
committed
Add test case for duplicated diagnostic issue
1 parent 4194af8 commit cf59e07

File tree

3 files changed

+142
-1
lines changed

3 files changed

+142
-1
lines changed

Tests/SwiftDocCTests/Semantics/MarkupReferenceResolverTests.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
This source file is part of the Swift.org open source project
33

4-
Copyright (c) 2022 Apple Inc. and the Swift project authors
4+
Copyright (c) 2022-2023 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
@@ -27,4 +27,11 @@ class MarkupReferenceResolverTests: XCTestCase {
2727
_ = resolver.visit(document)
2828
XCTAssertEqual(0, resolver.problems.count)
2929
}
30+
31+
func testDuplicatedDiagnosticForExtensionFile() throws {
32+
let (_, context) = try testBundleAndContext(named: "ExtensionArticleBundle")
33+
// Before #733's change, there will be 2 duplicated problems.
34+
// And we'll trigger a index out of range crash in DefaultDiagnosticConsoleFormatter
35+
XCTAssertEqual(1, context.problems.count)
36+
}
3037
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# ``Server``
2+
3+
<!-- The correct signature is ``Server/echo(_:)``-->
4+
Check this awesome function ``Server/echo()``
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
{
2+
"metadata": {
3+
"formatVersion": { "major": 0, "minor": 6, "patch": 0 },
4+
"generator": "Apple Swift version 5.9 (swiftlang-5.9.0.128.108 clang-1500.0.40.1)"
5+
},
6+
"module": {
7+
"name": "ServerKit",
8+
"platform": {
9+
"architecture": "arm64",
10+
"vendor": "apple",
11+
"operatingSystem": {
12+
"name": "ios",
13+
"minimumVersion": { "major": 12, "minor": 0 }
14+
}
15+
}
16+
},
17+
"symbols": [
18+
{
19+
"kind": {
20+
"identifier": "swift.method",
21+
"displayName": "Instance Method"
22+
},
23+
"identifier": {
24+
"precise": "s:9ServerKit0A0C4echoyySSF",
25+
"interfaceLanguage": "swift"
26+
},
27+
"pathComponents": ["Server", "echo(_:)"],
28+
"names": {
29+
"title": "echo(_:)",
30+
"subHeading": [
31+
{ "kind": "keyword", "spelling": "func" },
32+
{ "kind": "text", "spelling": " " },
33+
{ "kind": "identifier", "spelling": "echo" },
34+
{ "kind": "text", "spelling": "(" },
35+
{
36+
"kind": "typeIdentifier",
37+
"spelling": "String",
38+
"preciseIdentifier": "s:SS"
39+
},
40+
{ "kind": "text", "spelling": ")" }
41+
]
42+
},
43+
"functionSignature": {
44+
"parameters": [
45+
{
46+
"name": "message",
47+
"declarationFragments": [
48+
{ "kind": "identifier", "spelling": "message" },
49+
{ "kind": "text", "spelling": ": " },
50+
{
51+
"kind": "typeIdentifier",
52+
"spelling": "String",
53+
"preciseIdentifier": "s:SS"
54+
}
55+
]
56+
}
57+
],
58+
"returns": [{ "kind": "text", "spelling": "()" }]
59+
},
60+
"declarationFragments": [
61+
{ "kind": "keyword", "spelling": "func" },
62+
{ "kind": "text", "spelling": " " },
63+
{ "kind": "identifier", "spelling": "echo" },
64+
{ "kind": "text", "spelling": "(" },
65+
{ "kind": "externalParam", "spelling": "_" },
66+
{ "kind": "text", "spelling": " " },
67+
{ "kind": "internalParam", "spelling": "message" },
68+
{ "kind": "text", "spelling": ": " },
69+
{
70+
"kind": "typeIdentifier",
71+
"spelling": "String",
72+
"preciseIdentifier": "s:SS"
73+
},
74+
{ "kind": "text", "spelling": ")" }
75+
],
76+
"accessLevel": "public",
77+
"location": {
78+
"uri": "file:///tmp/Server.swift",
79+
"position": { "line": 2, "character": 16 }
80+
}
81+
},
82+
{
83+
"kind": { "identifier": "swift.class", "displayName": "Class" },
84+
"identifier": {
85+
"precise": "s:9ServerKit0A0C",
86+
"interfaceLanguage": "swift"
87+
},
88+
"pathComponents": ["Server"],
89+
"names": {
90+
"title": "Server",
91+
"navigator": [{ "kind": "identifier", "spelling": "Server" }],
92+
"subHeading": [
93+
{ "kind": "keyword", "spelling": "class" },
94+
{ "kind": "text", "spelling": " " },
95+
{ "kind": "identifier", "spelling": "Server" }
96+
]
97+
},
98+
"docComment": {
99+
"uri": "file:///tmp/Server.swift",
100+
"module": "ServerKit",
101+
"lines": [
102+
{
103+
"range": {
104+
"start": { "line": 0, "character": 4 },
105+
"end": { "line": 0, "character": 15 }
106+
},
107+
"text": "Hello World"
108+
}
109+
]
110+
},
111+
"declarationFragments": [
112+
{ "kind": "keyword", "spelling": "class" },
113+
{ "kind": "text", "spelling": " " },
114+
{ "kind": "identifier", "spelling": "Server" }
115+
],
116+
"accessLevel": "public",
117+
"location": {
118+
"uri": "file:///tmp/Server.swift",
119+
"position": { "line": 1, "character": 13 }
120+
}
121+
}
122+
],
123+
"relationships": [
124+
{
125+
"kind": "memberOf",
126+
"source": "s:9ServerKit0A0C4echoyySSF",
127+
"target": "s:9ServerKit0A0C"
128+
}
129+
]
130+
}

0 commit comments

Comments
 (0)