Skip to content

Commit e087327

Browse files
committed
fix tests
1 parent 760476c commit e087327

File tree

6 files changed

+44
-21
lines changed

6 files changed

+44
-21
lines changed

Tests/JExtractSwiftTests/JNI/JNIClassTests.swift

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,8 @@ struct JNIClassTests {
283283
func Java_com_example_swift_MyClass__00024doSomething__JJ(environment: UnsafeMutablePointer<JNIEnv?>!, thisClass: jclass, x: jlong, self: jlong) {
284284
assert(self != 0, "self memory address was null")
285285
let selfBits$ = Int(Int64(fromJNI: self, in: environment!))
286-
guard let self$ = UnsafeMutablePointer<MyClass>(bitPattern: selfBits$) else {
286+
let self$ = UnsafeMutablePointer<MyClass>(bitPattern: selfBits$)
287+
guard let self$ else {
287288
fatalError("self memory address was null in call to \\(#function)!")
288289
}
289290
self$.pointee.doSomething(x: Int64(fromJNI: x, in: environment!))
@@ -331,7 +332,8 @@ struct JNIClassTests {
331332
func Java_com_example_swift_MyClass__00024copy__J(environment: UnsafeMutablePointer<JNIEnv?>!, thisClass: jclass, self: jlong) -> jlong {
332333
assert(self != 0, "self memory address was null")
333334
let selfBits$ = Int(Int64(fromJNI: self, in: environment!))
334-
guard let self$ = UnsafeMutablePointer<MyClass>(bitPattern: selfBits$) else {
335+
let self$ = UnsafeMutablePointer<MyClass>(bitPattern: selfBits$)
336+
guard let self$ else {
335337
fatalError("self memory address was null in call to \\(#function)!")
336338
}
337339
let result$ = UnsafeMutablePointer<MyClass>.allocate(capacity: 1)
@@ -382,12 +384,14 @@ struct JNIClassTests {
382384
func Java_com_example_swift_MyClass__00024isEqual__JJ(environment: UnsafeMutablePointer<JNIEnv?>!, thisClass: jclass, other: jlong, self: jlong) -> jboolean {
383385
assert(other != 0, "other memory address was null")
384386
let otherBits$ = Int(Int64(fromJNI: other, in: environment!))
385-
guard let other$ = UnsafeMutablePointer<MyClass>(bitPattern: otherBits$) else {
387+
let other$ = UnsafeMutablePointer<MyClass>(bitPattern: otherBits$)
388+
guard let other$ else {
386389
fatalError("other memory address was null in call to \\(#function)!")
387390
}
388391
assert(self != 0, "self memory address was null")
389392
let selfBits$ = Int(Int64(fromJNI: self, in: environment!))
390-
guard let self$ = UnsafeMutablePointer<MyClass>(bitPattern: selfBits$) else {
393+
let self$ = UnsafeMutablePointer<MyClass>(bitPattern: selfBits$)
394+
guard let self$ else {
391395
fatalError("self memory address was null in call to \\(#function)!")
392396
}
393397
return self$.pointee.isEqual(to: other$.pointee).getJNIValue(in: environment!)

Tests/JExtractSwiftTests/JNI/JNIClosureTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ struct JNIClosureTests {
6161
expectedChunks: [
6262
"""
6363
@_cdecl("Java_com_example_swift_SwiftModule__00024emptyClosure__Lcom_example_swift_SwiftModule_00024emptyClosure_00024closure_2")
64-
func Java_com_example_swift_SwiftModule__00024emptyClosure__Lcom_example_swift_SwiftModule_00024emptyClosure_00024closure_2(environment: UnsafeMutablePointer<JNIEnv?>!, thisClass: jclass, closure: jobject) {
64+
func Java_com_example_swift_SwiftModule__00024emptyClosure__Lcom_example_swift_SwiftModule_00024emptyClosure_00024closure_2(environment: UnsafeMutablePointer<JNIEnv?>!, thisClass: jclass, closure: jobject?) {
6565
SwiftModule.emptyClosure(closure: {
6666
let class$ = environment!.interface.GetObjectClass(environment, closure)
6767
let methodID$ = environment!.interface.GetMethodID(environment, class$, "apply", "()V")!
@@ -113,7 +113,7 @@ struct JNIClosureTests {
113113
expectedChunks: [
114114
"""
115115
@_cdecl("Java_com_example_swift_SwiftModule__00024closureWithArgumentsAndReturn__Lcom_example_swift_SwiftModule_00024closureWithArgumentsAndReturn_00024closure_2")
116-
func Java_com_example_swift_SwiftModule__00024closureWithArgumentsAndReturn__Lcom_example_swift_SwiftModule_00024closureWithArgumentsAndReturn_00024closure_2(environment: UnsafeMutablePointer<JNIEnv?>!, thisClass: jclass, closure: jobject) {
116+
func Java_com_example_swift_SwiftModule__00024closureWithArgumentsAndReturn__Lcom_example_swift_SwiftModule_00024closureWithArgumentsAndReturn_00024closure_2(environment: UnsafeMutablePointer<JNIEnv?>!, thisClass: jclass, closure: jobject?) {
117117
SwiftModule.closureWithArgumentsAndReturn(closure: { _0, _1 in
118118
let class$ = environment!.interface.GetObjectClass(environment, closure)
119119
let methodID$ = environment!.interface.GetMethodID(environment, class$, "apply", "(JZ)J")!

Tests/JExtractSwiftTests/JNI/JNIJavaKitTests.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,14 @@ struct JNIJavaKitTests {
6464
expectedChunks: [
6565
"""
6666
@_cdecl("Java_com_example_swift_SwiftModule__00024function__Ljava_lang_Long_2Ljava_lang_Integer_2J")
67-
func Java_com_example_swift_SwiftModule__00024function__Ljava_lang_Long_2Ljava_lang_Integer_2J(environment: UnsafeMutablePointer<JNIEnv?>!, thisClass: jclass, javaLong: jobject, javaInteger: jobject, int: jlong) {
68-
SwiftModule.function(javaLong: JavaLong(javaThis: javaLong, environment: environment!), javaInteger: JavaInteger(javaThis: javaInteger, environment: environment!), int: Int64(fromJNI: int, in: environment!))
67+
func Java_com_example_swift_SwiftModule__00024function__Ljava_lang_Long_2Ljava_lang_Integer_2J(environment: UnsafeMutablePointer<JNIEnv?>!, thisClass: jclass, javaLong: jobject?, javaInteger: jobject?, int: jlong) {
68+
guard let javaLong_unwrapped$ = javaLong else {
69+
fatalError("javaLong was null in call to \\(#function), but Swift requires non-optional!")
70+
}
71+
guard let javaInteger_unwrapped$ = javaInteger else {
72+
fatalError("javaInteger was null in call to \\(#function), but Swift requires non-optional!")
73+
}
74+
SwiftModule.function(javaLong: JavaLong(javaThis: javaLong_unwrapped$, environment: environment!), javaInteger: JavaInteger(javaThis: javaInteger_unwrapped$, environment: environment!), int: Int64(fromJNI: int, in: environment!))
6975
}
7076
"""
7177
]

Tests/JExtractSwiftTests/JNI/JNIModuleTests.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ struct JNIModuleTests {
4545
4646
import org.swift.swiftkit.core.*;
4747
import org.swift.swiftkit.core.util.*;
48+
import java.util.*;
4849
import org.swift.swiftkit.core.annotations.*;
4950
5051
public final class SwiftModule {
@@ -176,7 +177,7 @@ struct JNIModuleTests {
176177
expectedChunks: [
177178
"""
178179
@_cdecl("Java_com_example_swift_SwiftModule__00024copy__Ljava_lang_String_2")
179-
func Java_com_example_swift_SwiftModule__00024copy__Ljava_lang_String_2(environment: UnsafeMutablePointer<JNIEnv?>!, thisClass: jclass, string: jstring) -> jstring {
180+
func Java_com_example_swift_SwiftModule__00024copy__Ljava_lang_String_2(environment: UnsafeMutablePointer<JNIEnv?>!, thisClass: jclass, string: jstring?) -> jstring? {
180181
return SwiftModule.copy(String(fromJNI: string, in: environment!)).getJNIValue(in: environment!)
181182
}
182183
""",

Tests/JExtractSwiftTests/JNI/JNIStructTests.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,8 @@ struct JNIStructTests {
205205
func Java_com_example_swift_MyStruct__00024doSomething__JJ(environment: UnsafeMutablePointer<JNIEnv?>!, thisClass: jclass, x: jlong, self: jlong) {
206206
assert(self != 0, "self memory address was null")
207207
let selfBits$ = Int(Int64(fromJNI: self, in: environment!))
208-
guard let self$ = UnsafeMutablePointer<MyStruct>(bitPattern: selfBits$) else {
208+
let self$ = UnsafeMutablePointer<MyStruct>(bitPattern: selfBits$)
209+
guard let self$ else {
209210
fatalError("self memory address was null in call to \\(#function)!")
210211
}
211212
self$.pointee.doSomething(x: Int64(fromJNI: x, in: environment!))

Tests/JExtractSwiftTests/JNI/JNIVariablesTests.swift

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ struct JNIVariablesTests {
7171
func Java_com_example_swift_MyClass__00024getConstant__J(environment: UnsafeMutablePointer<JNIEnv?>!, thisClass: jclass, self: jlong) -> jlong {
7272
assert(self != 0, "self memory address was null")
7373
let selfBits$ = Int(Int64(fromJNI: self, in: environment!))
74-
guard let self$ = UnsafeMutablePointer<MyClass>(bitPattern: selfBits$) else {
74+
let self$ = UnsafeMutablePointer<MyClass>(bitPattern: selfBits$)
75+
guard let self$ else {
7576
fatalError("self memory address was null in call to \\(#function)!")
7677
}
7778
return self$.pointee.constant.getJNIValue(in: environment!)
@@ -134,7 +135,8 @@ struct JNIVariablesTests {
134135
func Java_com_example_swift_MyClass__00024getMutable__J(environment: UnsafeMutablePointer<JNIEnv?>!, thisClass: jclass, self: jlong) -> jlong {
135136
assert(self != 0, "self memory address was null")
136137
let selfBits$ = Int(Int64(fromJNI: self, in: environment!))
137-
guard let self$ = UnsafeMutablePointer<MyClass>(bitPattern: selfBits$) else {
138+
let self$ = UnsafeMutablePointer<MyClass>(bitPattern: selfBits$)
139+
guard let self$ else {
138140
fatalError("self memory address was null in call to \\(#function)!")
139141
}
140142
return self$.pointee.mutable.getJNIValue(in: environment!)
@@ -145,7 +147,8 @@ struct JNIVariablesTests {
145147
func Java_com_example_swift_MyClass__00024setMutable__JJ(environment: UnsafeMutablePointer<JNIEnv?>!, thisClass: jclass, newValue: jlong, self: jlong) {
146148
assert(self != 0, "self memory address was null")
147149
let selfBits$ = Int(Int64(fromJNI: self, in: environment!))
148-
guard let self$ = UnsafeMutablePointer<MyClass>(bitPattern: selfBits$) else {
150+
let self$ = UnsafeMutablePointer<MyClass>(bitPattern: selfBits$)
151+
guard let self$ else {
149152
fatalError("self memory address was null in call to \\(#function)!")
150153
}
151154
self$.pointee.mutable = Int64(fromJNI: newValue, in: environment!)
@@ -194,7 +197,8 @@ struct JNIVariablesTests {
194197
func Java_com_example_swift_MyClass__00024getComputed__J(environment: UnsafeMutablePointer<JNIEnv?>!, thisClass: jclass, self: jlong) -> jlong {
195198
assert(self != 0, "self memory address was null")
196199
let selfBits$ = Int(Int64(fromJNI: self, in: environment!))
197-
guard let self$ = UnsafeMutablePointer<MyClass>(bitPattern: selfBits$) else {
200+
let self$ = UnsafeMutablePointer<MyClass>(bitPattern: selfBits$)
201+
guard let self$ else {
198202
fatalError("self memory address was null in call to \\(#function)!")
199203
}
200204
return self$.pointee.computed.getJNIValue(in: environment!)
@@ -243,7 +247,8 @@ struct JNIVariablesTests {
243247
func Java_com_example_swift_MyClass__00024getComputedThrowing__J(environment: UnsafeMutablePointer<JNIEnv?>!, thisClass: jclass, self: jlong) -> jlong {
244248
assert(self != 0, "self memory address was null")
245249
let selfBits$ = Int(Int64(fromJNI: self, in: environment!))
246-
guard let self$ = UnsafeMutablePointer<MyClass>(bitPattern: selfBits$) else {
250+
let self$ = UnsafeMutablePointer<MyClass>(bitPattern: selfBits$)
251+
guard let self$ else {
247252
fatalError("self memory address was null in call to \\(#function)!")
248253
}
249254
do {
@@ -311,7 +316,8 @@ struct JNIVariablesTests {
311316
func Java_com_example_swift_MyClass__00024getGetterAndSetter__J(environment: UnsafeMutablePointer<JNIEnv?>!, thisClass: jclass, self: jlong) -> jlong {
312317
assert(self != 0, "self memory address was null")
313318
let selfBits$ = Int(Int64(fromJNI: self, in: environment!))
314-
guard let self$ = UnsafeMutablePointer<MyClass>(bitPattern: selfBits$) else {
319+
let self$ = UnsafeMutablePointer<MyClass>(bitPattern: selfBits$)
320+
guard let self$ else {
315321
fatalError("self memory address was null in call to \\(#function)!")
316322
}
317323
return self$.pointee.getterAndSetter.getJNIValue(in: environment!)
@@ -322,7 +328,8 @@ struct JNIVariablesTests {
322328
func Java_com_example_swift_MyClass__00024setGetterAndSetter__JJ(environment: UnsafeMutablePointer<JNIEnv?>!, thisClass: jclass, newValue: jlong, self: jlong) {
323329
assert(self != 0, "self memory address was null")
324330
let selfBits$ = Int(Int64(fromJNI: self, in: environment!))
325-
guard let self$ = UnsafeMutablePointer<MyClass>(bitPattern: selfBits$) else {
331+
let self$ = UnsafeMutablePointer<MyClass>(bitPattern: selfBits$)
332+
guard let self$ else {
326333
fatalError("self memory address was null in call to \\(#function)!")
327334
}
328335
self$.pointee.getterAndSetter = Int64(fromJNI: newValue, in: environment!)
@@ -385,7 +392,8 @@ struct JNIVariablesTests {
385392
func Java_com_example_swift_MyClass__00024isSomeBoolean__J(environment: UnsafeMutablePointer<JNIEnv?>!, thisClass: jclass, self: jlong) -> jboolean {
386393
assert(self != 0, "self memory address was null")
387394
let selfBits$ = Int(Int64(fromJNI: self, in: environment!))
388-
guard let self$ = UnsafeMutablePointer<MyClass>(bitPattern: selfBits$) else {
395+
let self$ = UnsafeMutablePointer<MyClass>(bitPattern: selfBits$)
396+
guard let self$ else {
389397
fatalError("self memory address was null in call to \\(#function)!")
390398
}
391399
return self$.pointee.someBoolean.getJNIValue(in: environment!)
@@ -396,7 +404,8 @@ struct JNIVariablesTests {
396404
func Java_com_example_swift_MyClass__00024setSomeBoolean__ZJ(environment: UnsafeMutablePointer<JNIEnv?>!, thisClass: jclass, newValue: jboolean, self: jlong) {
397405
assert(self != 0, "self memory address was null")
398406
let selfBits$ = Int(Int64(fromJNI: self, in: environment!))
399-
guard let self$ = UnsafeMutablePointer<MyClass>(bitPattern: selfBits$) else {
407+
let self$ = UnsafeMutablePointer<MyClass>(bitPattern: selfBits$)
408+
guard let self$ else {
400409
fatalError("self memory address was null in call to \\(#function)!")
401410
}
402411
self$.pointee.someBoolean = Bool(fromJNI: newValue, in: environment!)
@@ -459,7 +468,8 @@ struct JNIVariablesTests {
459468
func Java_com_example_swift_MyClass__00024isBoolean__J(environment: UnsafeMutablePointer<JNIEnv?>!, thisClass: jclass, self: jlong) -> jboolean {
460469
assert(self != 0, "self memory address was null")
461470
let selfBits$ = Int(Int64(fromJNI: self, in: environment!))
462-
guard let self$ = UnsafeMutablePointer<MyClass>(bitPattern: selfBits$) else {
471+
let self$ = UnsafeMutablePointer<MyClass>(bitPattern: selfBits$)
472+
guard let self$ else {
463473
fatalError("self memory address was null in call to \\(#function)!")
464474
}
465475
return self$.pointee.isBoolean.getJNIValue(in: environment!)
@@ -470,7 +480,8 @@ struct JNIVariablesTests {
470480
func Java_com_example_swift_MyClass__00024setBoolean__ZJ(environment: UnsafeMutablePointer<JNIEnv?>!, thisClass: jclass, newValue: jboolean, self: jlong) {
471481
assert(self != 0, "self memory address was null")
472482
let selfBits$ = Int(Int64(fromJNI: self, in: environment!))
473-
guard let self$ = UnsafeMutablePointer<MyClass>(bitPattern: selfBits$) else {
483+
let self$ = UnsafeMutablePointer<MyClass>(bitPattern: selfBits$)
484+
guard let self$ else {
474485
fatalError("self memory address was null in call to \\(#function)!")
475486
}
476487
self$.pointee.isBoolean = Bool(fromJNI: newValue, in: environment!)

0 commit comments

Comments
 (0)