Skip to content

Commit 12ea579

Browse files
committed
Test.swift cleanup for usability
1 parent db2a306 commit 12ea579

File tree

1 file changed

+12
-5
lines changed
  • SwiftCompilerSources/Sources/Optimizer/Utilities

1 file changed

+12
-5
lines changed

SwiftCompilerSources/Sources/Optimizer/Utilities/Test.swift

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
// FunctionTest("my_new_test") { function, arguments, context in
1717
// }
1818
// - In SwiftCompilerSources/Sources/SIL/Test.swift's registerOptimizerTests
19-
// function, register the new test:
20-
// registerFunctionTest(myNewTest)
19+
// function, add a new argument to the variadic function:
20+
// registerFunctionTests(..., myNewTest)
2121
//
2222
//===----------------------------------------------------------------------===//
2323
//
@@ -100,7 +100,7 @@ struct FunctionTest {
100100
let name: String
101101
let invocation: FunctionTestInvocation
102102

103-
public init(name: String, invocation: @escaping FunctionTestInvocation) {
103+
public init(_ name: String, invocation: @escaping FunctionTestInvocation) {
104104
self.name = name
105105
self.invocation = invocation
106106
}
@@ -135,12 +135,19 @@ extension BridgedTestArguments {
135135
/// Registration of each test in the SIL module.
136136
public func registerOptimizerTests() {
137137
// Register each test.
138-
registerFunctionTest(parseTestSpecificationTest)
138+
registerFunctionTests(
139+
parseTestSpecificationTest,
140+
forwardingUseDefTest,
141+
forwardingDefUseTest
142+
)
139143

140144
// Finally register the thunk they all call through.
141145
registerFunctionTestThunk(functionTestThunk)
142146
}
143147

148+
private func registerFunctionTests(_ tests: FunctionTest...) {
149+
tests.forEach { registerFunctionTest($0) }
150+
}
144151

145152
private func registerFunctionTest(_ test: FunctionTest) {
146153
test.name._withBridgedStringRef { ref in
@@ -202,7 +209,7 @@ private func castToInvocation(fromOpaquePointer erasedInvocation: UnsafeMutableR
202209
// - its type
203210
// - something to identify the instance (mostly this means calling dump)
204211
let parseTestSpecificationTest =
205-
FunctionTest(name: "test_specification_parsing") { function, arguments, context in
212+
FunctionTest("test_specification_parsing") { function, arguments, context in
206213
let expectedFields = arguments.takeString()
207214
for expectedField in expectedFields.string {
208215
switch expectedField {

0 commit comments

Comments
 (0)