Skip to content

Commit d3a3315

Browse files
feat(core): remove Long constructor from JS
1 parent 661864f commit d3a3315

File tree

6 files changed

+10
-17
lines changed
  • kbigint/src
    • androidMain/kotlin/io/github/observeroftime/kbigint
    • commonMain/kotlin/io/github/observeroftime/kbigint
    • jsMain/kotlin/io/github/observeroftime/kbigint
    • jsTest/kotlin/io/github/observeroftime/kbigint
    • jvmMain/kotlin/io/github/observeroftime/kbigint
    • nativeMain/kotlin/io/github/observeroftime/kbigint

6 files changed

+10
-17
lines changed

kbigint/src/androidMain/kotlin/io/github/observeroftime/kbigint/KBigInt.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ actual class KBigInt private constructor(private var value: BigInteger) : Compar
1111

1212
actual constructor(number: Int) : this(number.toBigInteger())
1313

14-
actual constructor(number: Long) : this(number.toBigInteger())
14+
constructor(number: Long) : this(number.toBigInteger())
1515

1616
/** Convert a [ByteArray] to a [KBigInt]. */
1717
@Suppress("unused")

kbigint/src/commonMain/kotlin/io/github/observeroftime/kbigint/KBigInt.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ expect class KBigInt : Comparable<KBigInt> {
88
/** Convert an [Int] to a [KBigInt]. */
99
constructor(number: Int)
1010

11-
/** Convert a [Long] to a [KBigInt]. */
12-
constructor(number: Long)
13-
1411
/**
1512
* The sign of the value:
1613
*

kbigint/src/jsMain/kotlin/io/github/observeroftime/kbigint/KBigInt.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ actual class KBigInt private constructor(
1212
@JsName("fromNumber")
1313
actual constructor(number: Int) : this(BigInt(number))
1414

15-
@JsName("_fromLong")
16-
@Suppress("NON_EXPORTABLE_TYPE")
17-
actual constructor(number: Long) : this(BigInt(number))
18-
1915
actual val sign: Int
2016
get() = KBigIntUtils.sign(value)
2117

kbigint/src/jsTest/kotlin/io/github/observeroftime/kbigint/KBigIntTest.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import kotlin.test.*
44

55
actual class KBigIntTest {
66
companion object {
7-
private val long = KBigInt(OVER_MAX_INT)
7+
private val long = KBigInt(OVER_MAX_INT.toString())
88
private val string = KBigInt(OVER_MAX_LONG)
99
}
1010

@@ -20,7 +20,7 @@ actual class KBigIntTest {
2020
assertEquals(KBigInt("9223372039002259456"), string + long)
2121
assertEquals(KBigInt("9223372034707292160"), string - long)
2222
assertEquals(KBigInt("19807040628566084398385987584"), string * long)
23-
assertEquals(KBigInt(4294967296L), string / long)
23+
assertEquals(KBigInt("4294967296"), string / long)
2424
assertEquals(KBigInt(0), string % long)
2525
}
2626

@@ -33,7 +33,7 @@ actual class KBigIntTest {
3333

3434
@Test
3535
actual fun testNegate() {
36-
assertEquals(KBigInt(-OVER_MAX_INT), -long)
36+
assertEquals(KBigInt((-OVER_MAX_INT).toString()), -long)
3737
}
3838

3939
@Test
@@ -45,13 +45,13 @@ actual class KBigIntTest {
4545

4646
@Test
4747
actual fun testShifts() {
48-
assertEquals(KBigInt(8589934592L), long shl 2)
49-
assertEquals(KBigInt(1073741824L), long shr 1)
48+
assertEquals(KBigInt("8589934592"), long shl 2)
49+
assertEquals(KBigInt(1073741824), long shr 1)
5050
}
5151

5252
@Test
5353
actual fun testInvert() {
54-
assertEquals(KBigInt(-2147483649L), long.inv())
54+
assertEquals(KBigInt("-2147483649"), long.inv())
5555
}
5656

5757
@Test
@@ -85,7 +85,7 @@ actual class KBigIntTest {
8585
@Test
8686
actual fun testEquals() {
8787
assertFalse { long == string }
88-
assertTrue { long == KBigInt(OVER_MAX_INT) }
88+
assertTrue { long == KBigInt(OVER_MAX_INT.toString()) }
8989
}
9090

9191
@Test

kbigint/src/jvmMain/kotlin/io/github/observeroftime/kbigint/KBigInt.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ actual class KBigInt private constructor(private var value: BigInteger) : Compar
99

1010
actual constructor(number: Int) : this(number.toBigInteger())
1111

12-
actual constructor(number: Long) : this(number.toBigInteger())
12+
constructor(number: Long) : this(number.toBigInteger())
1313

1414
/** Convert a [ByteArray] to a [KBigInt]. */
1515
@Suppress("unused")

kbigint/src/nativeMain/kotlin/io/github/observeroftime/kbigint/KBigInt.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ actual class KBigInt private constructor(private var value: mp_int) : Comparable
4848
* @throws [IllegalStateException] if the operation fails
4949
*/
5050
@Throws(IllegalStateException::class)
51-
actual constructor(number: Long) : this() {
51+
constructor(number: Long) : this() {
5252
mp_init_i64(value.ptr, number).check()
5353
}
5454

0 commit comments

Comments
 (0)