Skip to content

Commit 2227da8

Browse files
committed
Improve unexpected swift nodes test
1 parent f3cb97b commit 2227da8

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

Tests/SafeDIToolTests/SafeDIToolCodeGenerationTests.swift

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5881,29 +5881,35 @@ struct SafeDIToolCodeGenerationTests: ~Copyable {
58815881
@Test
58825882
mutating func run_doesNotWriteConvenienceExtensionOnRootOfTree_whenUnexpectedSwiftNodesAreEncountered() async throws {
58835883
// If this test begins to fail after updating Swift, put the below code into an AST parser and see if unexpected nodes are still encountered.
5884-
// The following code generates unexpected nodes on Swift 6.2, but does not on Swift `main`.
58855884
let output = try await executeSafeDIToolTest(
58865885
swiftFileContent: [
58875886
"""
58885887
@Instantiable
58895888
public final class A: Instantiable {
5890-
public init() {}
5889+
public init(b: B) {
5890+
self.b = b
5891+
}
58915892
58925893
private var foo: Foo {
5893-
.init(
5894-
a: {},
5895-
b: {} // oh no! Missing trailing comma!
5896-
c: {},
5897-
d: { [weak self] in
5898-
guard let self else { return }
5899-
doSomething()
5900-
},
5901-
)
5894+
.init(
5895+
a: {},
5896+
b: {} // oh no! Missing trailing comma!
5897+
c: {},
5898+
d: { [weak self] in
5899+
guard let self else { return }
5900+
doSomething()
5901+
},
5902+
)
59025903
}
5903-
5904-
func doSomething() {}
5904+
5905+
private func doSomething() {
5906+
SomeModule:: // on no! Missing code after the module selector
5907+
}
5908+
5909+
@Instantiated private let b: B
59055910
}
59065911
5912+
// In some versions of Swift, the class B cannot be found because earlier code included parser-breaking syntax.
59075913
@Instantiable
59085914
public final class B: Instantiable {
59095915
public init() {}

0 commit comments

Comments
 (0)