Skip to content
This repository has been archived by the owner on Aug 10, 2021. It is now read-only.

Commit

Permalink
Add more tests for @Throws
Browse files Browse the repository at this point in the history
  • Loading branch information
SvyatoslavScherbina committed Feb 6, 2020
1 parent c9823a9 commit 43f59c7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions backend.native/tests/framework/values/expectedLazy.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:)")));
Expand Down
3 changes: 3 additions & 0 deletions backend.native/tests/framework/values/values.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions backend.native/tests/framework/values/values.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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 {
Expand Down

0 comments on commit 43f59c7

Please sign in to comment.