Skip to content

Commit 3c71e83

Browse files
committed
move entirely over to swift testing
1 parent e7d7a21 commit 3c71e83

File tree

5 files changed

+38
-62
lines changed

5 files changed

+38
-62
lines changed

Tests/JExtractSwiftTests/Asserts/TextAssertions.swift

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,17 @@
1212
//===----------------------------------------------------------------------===//
1313

1414
import JExtractSwift
15-
import XCTest
15+
import Testing
16+
import struct Foundation.CharacterSet
1617

17-
func assertOutput(_ got: String, expected: String, file: StaticString = #filePath, line: UInt = #line) {
18+
func assertOutput(
19+
_ got: String,
20+
expected: String,
21+
fileID: String = #fileID,
22+
filePath: String = #filePath,
23+
line: Int = #line,
24+
column: Int = #column
25+
) {
1826
let gotLines = got.split(separator: "\n")
1927
let expectedLines = expected.split(separator: "\n")
2028

@@ -39,7 +47,9 @@ func assertOutput(_ got: String, expected: String, file: StaticString = #filePat
3947

4048
diffLineNumbers.append(no)
4149

42-
XCTAssertEqual(ge, ee, file: file, line: line)
50+
let sourceLocation = SourceLocation(
51+
fileID: fileID, filePath: filePath, line: line, column: column)
52+
#expect(ge == ee, sourceLocation: sourceLocation)
4353
}
4454

4555
}

Tests/JExtractSwiftTests/FuncImportTests.swift

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@
1212
//===----------------------------------------------------------------------===//
1313

1414
import JExtractSwift
15-
import XCTest
15+
import Testing
1616

17-
// TODO: Adopt Testing instead
18-
final class MethodImportTests: XCTestCase {
17+
final class MethodImportTests {
1918
let class_interfaceFile =
2019
"""
2120
// swift-interface-format-version: 1.0
@@ -51,7 +50,7 @@ final class MethodImportTests: XCTestCase {
5150
}
5251
"""
5352

54-
func test_method_helloWorld() async throws {
53+
@Test func method_helloWorld() async throws {
5554
let st = Swift2JavaTranslator(
5655
javaPackage: "com.example.swift",
5756
swiftModuleName: "__FakeModule"
@@ -90,7 +89,7 @@ final class MethodImportTests: XCTestCase {
9089
)
9190
}
9291

93-
func test_method_globalTakeInt() async throws {
92+
@Test func method_globalTakeInt() async throws {
9493
let st = Swift2JavaTranslator(
9594
javaPackage: "com.example.swift",
9695
swiftModuleName: "__FakeModule"
@@ -131,7 +130,7 @@ final class MethodImportTests: XCTestCase {
131130
)
132131
}
133132

134-
func test_method_globalTakeIntLongString() async throws {
133+
@Test func method_globalTakeIntLongString() async throws {
135134
let st = Swift2JavaTranslator(
136135
javaPackage: "com.example.swift",
137136
swiftModuleName: "__FakeModule"
@@ -172,7 +171,7 @@ final class MethodImportTests: XCTestCase {
172171
)
173172
}
174173

175-
func test_method_class_helloMemberFunction_self_memorySegment() async throws {
174+
@Test func method_class_helloMemberFunction_self_memorySegment() async throws {
176175
let st = Swift2JavaTranslator(
177176
javaPackage: "com.example.swift",
178177
swiftModuleName: "__FakeModule"
@@ -215,7 +214,7 @@ final class MethodImportTests: XCTestCase {
215214
)
216215
}
217216

218-
func test_method_class_helloMemberFunction_self_wrapper() async throws {
217+
@Test func method_class_helloMemberFunction_self_wrapper() async throws {
219218
let st = Swift2JavaTranslator(
220219
javaPackage: "com.example.swift",
221220
swiftModuleName: "__FakeModule"
@@ -258,7 +257,7 @@ final class MethodImportTests: XCTestCase {
258257
)
259258
}
260259

261-
func test_method_class_helloMemberFunction_wrapper() async throws {
260+
@Test func method_class_helloMemberFunction_wrapper() async throws {
262261
let st = Swift2JavaTranslator(
263262
javaPackage: "com.example.swift",
264263
swiftModuleName: "__FakeModule"
@@ -293,7 +292,7 @@ final class MethodImportTests: XCTestCase {
293292
)
294293
}
295294

296-
func test_method_class_makeInt_wrapper() async throws {
295+
@Test func method_class_makeInt_wrapper() async throws {
297296
let st = Swift2JavaTranslator(
298297
javaPackage: "com.example.swift",
299298
swiftModuleName: "__FakeModule"

Tests/JExtractSwiftTests/FunctionDescriptorImportTests.swift

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
//===----------------------------------------------------------------------===//
1313

1414
import JExtractSwift
15-
import XCTest
15+
import Testing
1616

17-
// TODO: Adopt Testing instead
18-
final class FunctionDescriptorTests: XCTestCase {
17+
@Suite
18+
final class FunctionDescriptorTests {
1919
let interfaceFile =
2020
"""
2121
// swift-interface-format-version: 1.0
@@ -73,7 +73,8 @@ final class FunctionDescriptorTests: XCTestCase {
7373
try await body(output)
7474
}
7575

76-
func test_FunctionDescriptor_globalTakeInt() async throws {
76+
@Test
77+
func FunctionDescriptor_globalTakeInt() async throws {
7778
try await functionDescriptorTest("globalTakeInt") { output in
7879
assertOutput(
7980
output,
@@ -87,7 +88,8 @@ final class FunctionDescriptorTests: XCTestCase {
8788
}
8889
}
8990

90-
func test_FunctionDescriptor_globalTakeLongIntString() async throws {
91+
@Test
92+
func FunctionDescriptor_globalTakeLongIntString() async throws {
9193
try await functionDescriptorTest("globalTakeLongInt") { output in
9294
assertOutput(
9395
output,
@@ -102,7 +104,8 @@ final class FunctionDescriptorTests: XCTestCase {
102104
}
103105
}
104106

105-
func test_FunctionDescriptor_echoInt() async throws {
107+
@Test
108+
func FunctionDescriptor_echoInt() async throws {
106109
try await functionDescriptorTest("echoInt") { output in
107110
assertOutput(
108111
output,

Tests/JExtractSwiftTests/InitClassImportTests.swift

Lines changed: 0 additions & 38 deletions
This file was deleted.

Tests/JExtractSwiftTests/SwiftDylibTests.swift

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,24 @@
1212
//===----------------------------------------------------------------------===//
1313

1414
import JExtractSwift
15-
import XCTest
15+
import Testing
1616

17-
final class SwiftDylibTests: XCTestCase {
17+
final class SwiftDylibTests {
18+
19+
@Test
1820
func test_nm() async throws {
1921
let dylib = SwiftDylib(path: ".build/arm64-apple-macosx/debug/libJavaKitExample.dylib")!
2022

2123
let names = try await dylib.nmSymbolNames(grepDemangled: ["MySwiftClass", "len"])
2224

23-
XCTAssertTrue(
25+
#expect(
2426
names.contains {
2527
$0.descriptiveName.contains("JavaKitExample.MySwiftClass.len.getter")
2628
}
2729
)
2830

2931
let getter = names.findPropertyGetter()
30-
XCTAssertEqual(getter?.mangledName, "$s14JavaKitExample12MySwiftClassC3lenSivg")
31-
XCTAssertEqual(getter?.descriptiveName, "JavaKitExample.MySwiftClass.len.getter : Swift.Int")
32+
#expect(getter?.mangledName == "$s14JavaKitExample12MySwiftClassC3lenSivg")
33+
#expect(getter?.descriptiveName == "JavaKitExample.MySwiftClass.len.getter : Swift.Int")
3234
}
3335
}

0 commit comments

Comments
 (0)