Closed Roukanken42 closed 3 years ago
Hi @Roukanken42, I removed the legacy version some time ago because it wouldn't compile correctly with Kotlin 1.4 (at the time it was actually 1.4 prerelease, M1 or something around that)
I'll give it another try and see if it works, and then release it in the new version.
I tried it again with both legacy and IR enabled, unfortunately there are failing tests
com.ionspin.kotlin.bignum.decimal.BigDecimalDivPowTest.testIntegerDivision FAILED
undefined is not a function (evaluating 'closure$quotient.equals(toBigDecimal_0(2))')
/home/ionspin/Projects/Future/KotlinBigInteger/bignum/src/commonTest/kotlin/com/ionspin/kotlin/bignum/decimal/BigDecimalDivPowTest.kt
com.ionspin.kotlin.bignum.decimal.BigDecimalDivPowTest.testSpecificIntegerDivision FAILED
undefined is not a function (evaluating 'closure$quotient.equals(toBigDecimal_1(kotlin_js_internal_ShortCompanionObject.MIN_VALUE))')
/home/ionspin/Projects/Future/KotlinBigInteger/bignum/src/commonTest/kotlin/com/ionspin/kotlin/bignum/decimal/BigDecimalDivPowTest.kt
com.ionspin.kotlin.bignum.decimal.BigDecimalRoundingTests.testNumberOfDigits FAILED
undefined is not a function (evaluating '(1).lessThanOrEqual(tmp$_1)')
numberOfDecimalDigits@/home/ionspin/Projects/Future/KotlinBigInteger/bignum/src/commonMain/kotlin/com/ionspin/kotlin/bignum/decimal/BigDecimal.kt
I will look into this, but I can't give you any kind of commitment when and if I can fix it (might be on the kotlin compiler side, since it's only failing for legacy flavour)
I looked at it briefly too, and the first two are definitely fault of the Kotlin's compiler - something is wrong with closures. I suspect it might be the fault of contract on assertTrue not being properly implemented
For example a test like this:
@Test
fun testExample() {
val (a, _) = 1 to 2
assertTrue {
a == 1
}
}
gets compiled to
function Test$testExample$lambda(closure$a) {
return function () {
return closure$a === 1;
};
}
Test.prototype.testExample = function () {
var a = {v: to(1, 2).component1()};
assertTrue(void 0, Test$testExample$lambda(a));
};
eg, the closure is comparing {v: 1}
and 1
- it obviously comes out as false...
Same thing happens in the divrem
test's that are failing - it tries invoking functions on {v: <BigDecimal>}
and not on BigDecimal due to wrong closure capture. Imho, these two could be just solved by doing the whole test in the closure - since this happens with integers & pair too...
Haven't yet looked what's happening on the third one tho.
That is a great observation! I'll try wrapping the whole test in closure and see what happens in those two cases.
Hey @Roukanken42 wrapping tests inside assertTrue as you recommended and changing one range to use long instead of an int fixed all failing tests. The changes are being built at the moment and you should be able to use legacy js in 0.2.4-SNAPSHOT once the build is done!
I'm trying to use this library in multiplatform project as common dependency, but due to some other libraries I can't use IR compiler on Kotlin/JS
I noticed that released is only IR on Kotlin/JS, could you release it with both IR and Legacy? Eg, configuring according to this you can easily release both versions.
Not sure if there is any other problem with this solution.