Skip to content

Commit 09a1c3b

Browse files
committed
Update test
1 parent 3086055 commit 09a1c3b

2 files changed

Lines changed: 37 additions & 1 deletion

File tree

Sources/JExtractSwiftLib/JNI/JNICaching.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ enum JNICaching {
3030
}
3131

3232
static func cacheMemberName(for translatedEnumCase: JNISwift2JavaGenerator.TranslatedEnumCase) -> String {
33-
cacheMemberName(for: translatedEnumCase.original)
33+
cacheMemberName(for: translatedEnumCase.original)
3434
}
3535
}

Tests/JExtractSwiftTests/JNI/JNIEnumTests.swift

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,12 @@ struct JNIEnumTests {
305305
.swift,
306306
detectChunkByInitialLines: 1,
307307
expectedChunks: [
308+
"""
309+
enum _JNI_MyEnum {
310+
static let myEnumSecondCache = _JNIMethodIDCache(className: "com/example/swift/MyEnum$Second$_NativeParameters", methods: [.init(name: "<init>", signature: "(Ljava/lang/String;)V")])
311+
static let myEnumThirdCache = _JNIMethodIDCache(className: "com/example/swift/MyEnum$Third$_NativeParameters", methods: [.init(name: "<init>", signature: "(JI)V")])
312+
}
313+
""",
308314
"""
309315
@_cdecl("Java_com_example_swift_MyEnum__00024getAsSecond__J")
310316
public func Java_com_example_swift_MyEnum__00024getAsSecond__J(environment: UnsafeMutablePointer<JNIEnv?>!, thisClass: jclass, selfPointer: jlong) -> jobject? {
@@ -335,6 +341,36 @@ struct JNIEnumTests {
335341
return environment.interface.NewObjectA(environment, class$, constructorID$, newObjectArgs$)
336342
}
337343
""",
344+
],
345+
notExpectedChunks: [
346+
"public func Java_com_example_swift_MyEnum__00024getAsFirst__J("
347+
]
348+
)
349+
}
350+
351+
@Test
352+
func nonGeneratesGetAsCase_swift() throws {
353+
try assertOutput(
354+
input: """
355+
public enum MyEnum {
356+
case first
357+
case second
358+
}
359+
""",
360+
.jni,
361+
.swift,
362+
detectChunkByInitialLines: 1,
363+
expectedChunks: [],
364+
notExpectedChunks: [
365+
"""
366+
enum _JNI_MyEnum
367+
""",
368+
"""
369+
public func Java_com_example_swift_MyEnum__00024getAsFirst__J("
370+
""",
371+
"""
372+
public func Java_com_example_swift_MyEnum__00024getAsSecond__J(
373+
""",
338374
]
339375
)
340376
}

0 commit comments

Comments
 (0)