Skip to content

Commit 324ba59

Browse files
authored
Merge branch 'main' into jextract-nominal-type-resolution
2 parents 42a64e4 + 973b378 commit 324ba59

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
@@ -56,7 +55,7 @@ final class MethodImportTests: XCTestCase {
5655
}
5756
"""
5857

59-
func test_method_helloWorld() async throws {
58+
@Test func method_helloWorld() async throws {
6059
let st = Swift2JavaTranslator(
6160
javaPackage: "com.example.swift",
6261
swiftModuleName: "__FakeModule"
@@ -95,7 +94,7 @@ final class MethodImportTests: XCTestCase {
9594
)
9695
}
9796

98-
func test_method_globalTakeInt() async throws {
97+
@Test func method_globalTakeInt() async throws {
9998
let st = Swift2JavaTranslator(
10099
javaPackage: "com.example.swift",
101100
swiftModuleName: "__FakeModule"
@@ -136,7 +135,7 @@ final class MethodImportTests: XCTestCase {
136135
)
137136
}
138137

139-
func test_method_globalTakeIntLongString() async throws {
138+
@Test func method_globalTakeIntLongString() async throws {
140139
let st = Swift2JavaTranslator(
141140
javaPackage: "com.example.swift",
142141
swiftModuleName: "__FakeModule"
@@ -177,7 +176,7 @@ final class MethodImportTests: XCTestCase {
177176
)
178177
}
179178

180-
func test_method_class_helloMemberFunction_self_memorySegment() async throws {
179+
@Test func method_class_helloMemberFunction_self_memorySegment() async throws {
181180
let st = Swift2JavaTranslator(
182181
javaPackage: "com.example.swift",
183182
swiftModuleName: "__FakeModule"
@@ -218,7 +217,7 @@ final class MethodImportTests: XCTestCase {
218217
)
219218
}
220219

221-
func test_method_class_helloMemberInExtension_self_memorySegment() async throws {
220+
@Test func method_class_helloMemberFunction_self_wrapper() async throws {
222221
let st = Swift2JavaTranslator(
223222
javaPackage: "com.example.swift",
224223
swiftModuleName: "__FakeModule"
@@ -300,7 +299,7 @@ final class MethodImportTests: XCTestCase {
300299
)
301300
}
302301

303-
func test_method_class_helloMemberFunction_wrapper() async throws {
302+
@Test func method_class_helloMemberFunction_wrapper() async throws {
304303
let st = Swift2JavaTranslator(
305304
javaPackage: "com.example.swift",
306305
swiftModuleName: "__FakeModule"
@@ -333,7 +332,7 @@ final class MethodImportTests: XCTestCase {
333332
)
334333
}
335334

336-
func test_method_class_makeInt_wrapper() async throws {
335+
@Test func method_class_makeInt_wrapper() async throws {
337336
let st = Swift2JavaTranslator(
338337
javaPackage: "com.example.swift",
339338
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)