Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Commit b7ee28f

Browse files
committed
Add testComputedPropertiesWithMultipleAccessModifiersInPublicExtension
1 parent 06f4167 commit b7ee28f

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

Tests/SwiftDocTests/InterfaceTypeTests.swift

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,45 @@ final class InterfaceTypeTests: XCTestCase {
124124
XCTAssertEqual(module.interface.symbols[1].name, "b", "Property `b` should be in documented interface")
125125
}
126126

127+
func testComputedPropertiesWithMultipleAccessModifiersInPublicExtension() throws {
128+
let source = #"""
129+
public extension Int {
130+
internal(set) var a: Int {
131+
get { 1 }
132+
set {}
133+
}
134+
private(set) var b: Int {
135+
get { 1 }
136+
set {}
137+
}
138+
public internal(set) var c: Int {
139+
get { 1 }
140+
set {}
141+
}
142+
public private(set) var d: Int {
143+
get { 1 }
144+
set {}
145+
}
146+
}
147+
"""#
148+
149+
let url = try temporaryFile(contents: source)
150+
let sourceFile = try SourceFile(file: url, relativeTo: url.deletingLastPathComponent())
151+
let module = Module(name: "Module", sourceFiles: [sourceFile])
152+
153+
XCTAssertEqual(sourceFile.symbols.count, 4)
154+
XCTAssertTrue(sourceFile.symbols[0].isPublic, "Property `a` should be marked as public - the visibility of its getter is public")
155+
XCTAssertTrue(sourceFile.symbols[0].isPublic, "Property `b` should be marked as public - the visibility of its getter is public")
156+
XCTAssertTrue(sourceFile.symbols[0].isPublic, "Property `c` should be marked as public - the visibility of its getter is public")
157+
XCTAssertTrue(sourceFile.symbols[0].isPublic, "Property `d` should be marked as public - the visibility of its getter is public")
158+
159+
XCTAssertEqual(module.interface.symbols.count, 4)
160+
XCTAssertEqual(module.interface.symbols[0].name, "a", "Property `a` should be in documented interface")
161+
XCTAssertEqual(module.interface.symbols[1].name, "b", "Property `b` should be in documented interface")
162+
XCTAssertEqual(module.interface.symbols[2].name, "c", "Property `c` should be in documented interface")
163+
XCTAssertEqual(module.interface.symbols[3].name, "d", "Property `d` should be in documented interface")
164+
}
165+
127166
func testNestedPropertiesInPublicExtension() throws {
128167
let source = #"""
129168
public class RootController {}

0 commit comments

Comments
 (0)