Support for Unsigned Types in swift export #KT-65668 fixed
Merge-request: KT-MR-14300 Merged-by: Artem Olkov <artem.olkov@jetbrains.com>
This commit is contained in:
@@ -12,4 +12,20 @@ fun fooInt(): Int {
|
||||
|
||||
fun fooLong(): Long {
|
||||
return -1
|
||||
}
|
||||
|
||||
fun fooUByte(): UByte {
|
||||
return 0u
|
||||
}
|
||||
|
||||
fun fooUShort(): UShort {
|
||||
return 0u
|
||||
}
|
||||
|
||||
fun fooUInt(): UInt {
|
||||
return 0u
|
||||
}
|
||||
|
||||
fun fooULong(): ULong {
|
||||
return 0u
|
||||
}
|
||||
@@ -14,6 +14,24 @@ func smoke() throws {
|
||||
|
||||
try assertEquals(actual: org.kotlin.plus(a: 1, b: 2, c: 3), expected: 1 + 2 + 3)
|
||||
|
||||
// we expect strange stuff for plus and minus if UInt8 and UInt16 because kotlin behaves that way:
|
||||
// https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-u-byte/minus.html
|
||||
try assertEquals(actual: fooUByte(), expected: UInt8.min)
|
||||
try assertEquals(actual: org.kotlin.minus(a: fooUByte(), b: UInt8(1)), expected: UInt32.max)
|
||||
try assertEquals(actual: org.kotlin.plus(a: UInt8.max, b: UInt8(1)), expected: UInt32(256))
|
||||
|
||||
try assertEquals(actual: fooUShort(), expected: UInt16.min)
|
||||
try assertEquals(actual: org.kotlin.minus(a: fooUShort(), b: UInt16(1)), expected: UInt32.max)
|
||||
try assertEquals(actual: org.kotlin.plus(a: UInt16.max, b: UInt16(1)), expected: UInt32(65536))
|
||||
|
||||
try assertEquals(actual: fooUInt(), expected: UInt32.min)
|
||||
try assertEquals(actual: org.kotlin.minus(a: fooUInt(), b: UInt32(1)), expected: UInt32.max)
|
||||
try assertEquals(actual: org.kotlin.plus(a: UInt32.max, b: UInt32(1)), expected: UInt32.min)
|
||||
|
||||
try assertEquals(actual: fooULong(), expected: UInt64.min)
|
||||
try assertEquals(actual: org.kotlin.minus(a: fooULong(), b: UInt64(1)), expected: UInt64.max)
|
||||
try assertEquals(actual: org.kotlin.plus(a: UInt64.max, b: UInt64(1)), expected: UInt64.min)
|
||||
|
||||
try assertEquals(actual: org.kotlin.logicalOr(a: true, b: true), expected: true || true)
|
||||
try assertEquals(actual: org.kotlin.logicalOr(a: true, b: false), expected: true || false)
|
||||
try assertEquals(actual: org.kotlin.logicalOr(a: false, b: false), expected: false || false)
|
||||
|
||||
+13
-1
@@ -5,4 +5,16 @@ fun plus(a: Int, b: Int, c: Int) =
|
||||
|
||||
fun logicalOr(a: Boolean, b: Boolean) = a || b
|
||||
|
||||
fun xor(a: Boolean, b: Boolean) = a xor b
|
||||
fun xor(a: Boolean, b: Boolean) = a xor b
|
||||
|
||||
fun plus(a: UByte, b: UByte) = a + b
|
||||
fun minus(a: UByte, b: UByte) = a - b
|
||||
|
||||
fun plus(a: UShort, b: UShort) = a + b
|
||||
fun minus(a: UShort, b: UShort) = a - b
|
||||
|
||||
fun plus(a: UInt, b: UInt) = a + b
|
||||
fun minus(a: UInt, b: UInt) = a - b
|
||||
|
||||
fun plus(a: ULong, b: ULong) = a + b
|
||||
fun minus(a: ULong, b: ULong) = a - b
|
||||
Reference in New Issue
Block a user