Support variadic Objective-C methods

This commit is contained in:
Svyatoslav Scherbina
2019-04-12 17:17:47 +03:00
committed by SvyatoslavScherbina
parent 79e36a31cf
commit e437339d9a
9 changed files with 181 additions and 79 deletions
@@ -21,6 +21,7 @@ fun run() {
testExceptions()
testBlocks()
testCustomRetain()
testVarargs()
assertEquals(2, ForwardDeclaredEnum.TWO.value)
@@ -256,6 +257,32 @@ fun testCustomRetain() {
assertFalse(unexpectedDeallocation)
}
fun testVarargs() {
assertEquals(
"a b -1",
TestVarargs.testVarargsWithFormat(
"%@ %s %d",
"a" as NSString, "b".cstr, (-1).toByte()
).formatted
)
assertEquals(
"2 3 9223372036854775807",
TestVarargs(
"%d %d %lld",
2.toShort(), 3, Long.MAX_VALUE
).formatted
)
assertEquals(
"0.1 0.2 1 0",
TestVarargs.create(
"%.1f %.1lf %d %d",
0.1.toFloat(), 0.2, true, false
).formatted
)
}
private class MyException : Throwable()
fun nsArrayOf(vararg elements: Any): NSArray = NSMutableArray().apply {