Skip to content

Commit 0cf2ae2

Browse files
committed
Add extra test case for Playgrounds not being imported
1 parent ff218ca commit 0cf2ae2

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

Tests/SourceKitLSPTests/DocumentPlaygroundDiscoveryTests.swift

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,50 @@ final class DocumentPlaygroundDiscoveryTests: XCTestCase {
8181
)
8282
}
8383

84+
func testNoImportPlaygroundsTests() async throws {
85+
let project = try await SwiftPMTestProject(
86+
files: [
87+
"Sources/MyLibrary/MyLib.swift": """
88+
public func foo() -> String {
89+
"bar"
90+
}
91+
92+
#Playground("foo") {
93+
print(foo())
94+
}
95+
96+
#Playground {
97+
print(foo())
98+
}
99+
100+
public func bar(_ i: Int, _ j: Int) -> Int {
101+
i + j
102+
}
103+
104+
#Playground("bar") {
105+
var i = bar(1, 2)
106+
i = i + 1
107+
print(i)
108+
}
109+
"""
110+
],
111+
manifest: """
112+
import PackageDescription
113+
let package = Package(
114+
name: "MyLibrary",
115+
targets: [.target(name: "MyLibrary")]
116+
)
117+
""",
118+
enableBackgroundIndexing: false
119+
)
120+
121+
let (uri, _) = try project.openDocument("MyLib.swift")
122+
let playgrounds = try await project.testClient.send(
123+
DocumentPlaygroundsRequest(textDocument: TextDocumentIdentifier(uri))
124+
)
125+
XCTAssertEqual(playgrounds, [])
126+
}
127+
84128
func testParseNoPlaygroundsTests() async throws {
85129
let project = try await SwiftPMTestProject(
86130
files: [

0 commit comments

Comments
 (0)