Add more tests for @Throws
This commit is contained in:
committed by
SvyatoslavScherbina
parent
85b9200bc2
commit
4b97d8cad6
@@ -1102,6 +1102,7 @@ __attribute__((swift_name("ValuesKt")))
|
||||
+ (BOOL)isFrozenObj:(id)obj __attribute__((swift_name("isFrozen(obj:)")));
|
||||
+ (id)kotlinLambdaBlock:(id (^)(id))block __attribute__((swift_name("kotlinLambda(block:)")));
|
||||
+ (int64_t)multiplyInt:(int32_t)int_ long:(int64_t)long_ __attribute__((swift_name("multiply(int:long:)")));
|
||||
+ (id _Nullable)callFoo1Bridge:(ValuesBridgeBase *)bridge error:(NSError * _Nullable * _Nullable)error __attribute__((swift_name("callFoo1(bridge:)")));
|
||||
+ (id)same:(id)receiver __attribute__((swift_name("same(_:)")));
|
||||
+ (ValuesInt * _Nullable)callBase1:(id<ValuesBase1>)base1 value:(ValuesInt * _Nullable)value __attribute__((swift_name("call(base1:value:)")));
|
||||
+ (ValuesInt * _Nullable)callExtendedBase1:(id<ValuesExtendedBase1>)extendedBase1 value:(ValuesInt * _Nullable)value __attribute__((swift_name("call(extendedBase1:value:)")));
|
||||
|
||||
@@ -272,6 +272,9 @@ class Bridge : BridgeBase() {
|
||||
override fun foo4() = throw MyException()
|
||||
}
|
||||
|
||||
@Throws(NullPointerException::class)
|
||||
fun callFoo1(bridge: BridgeBase) = bridge.foo1()
|
||||
|
||||
fun Any.same() = this
|
||||
|
||||
// https://github.com/JetBrains/kotlin-native/issues/2571
|
||||
|
||||
@@ -275,6 +275,13 @@ func testFunctions() throws {
|
||||
try assertEquals(actual: ValuesKt.multiply(int: 3, long: 2), expected: 6)
|
||||
}
|
||||
|
||||
class BridgeSwift : BridgeBase {
|
||||
class Err : Error {}
|
||||
|
||||
override func foo1() throws -> Any {
|
||||
throw Err()
|
||||
}
|
||||
}
|
||||
|
||||
func testExceptions() throws {
|
||||
let bridge = Bridge()
|
||||
@@ -300,6 +307,13 @@ func testExceptions() throws {
|
||||
} catch let error as NSError {
|
||||
try assertTrue(error.kotlinException is MyException)
|
||||
}
|
||||
do {
|
||||
try ValuesKt.callFoo1(bridge: BridgeSwift())
|
||||
} catch let error as BridgeSwift.Err {
|
||||
// Ok
|
||||
} catch {
|
||||
try assertTrue(false)
|
||||
}
|
||||
}
|
||||
|
||||
func testFuncType() throws {
|
||||
|
||||
Reference in New Issue
Block a user