https://kotlinlang.org logo
Title
j

James Eschner

04/02/2021, 1:14 PM
Ran into an issue using
Arb.bigDecimal()
. Code:
class MyTest : ShouldSpec({
    should("be able to use bigDecimal") {
        // It would be great if Arb.bigDecimal() actually worked here :)
        checkAll(Arb.bigDecimal()) { bigDecimal ->
            true shouldBe true
        }
    }
})
~~~ Kotest Configuration ~~~
Character I is neither a decimal digit number, decimal point, nor "e" notation exponential mark.
java.lang.NumberFormatException: Character I is neither a decimal digit number, decimal point, nor "e" notation exponential mark.
	at java.base/java.math.BigDecimal.<init>(BigDecimal.java:518)

MyTest > should be able to use bigDecimal FAILED
    java.lang.NumberFormatException at MyTest.kt:33
        Caused by: java.lang.NumberFormatException at MyTest.kt:33
If we look at the implementation of
bigDecimal()
I can see why it’s failing, it’s simply taking
Arb.double()
and calling the
toBigDecimal()
extension function which fails on inputs like
Double.NEGATIVE_INFINITY
and
Double.POSITIVE_INFINITY
. Is this a bug or am I using
Arb.bigDecimal()
incorrectly? * Not a Contribution *
a

Ashish Kumar Joy

04/02/2021, 1:42 PM
Try the latest snapshot version, we had change the implementation of Arb.bigdecimal but is not currently released. https://github.com/kotest/kotest/pull/2135
j

James Eschner

04/02/2021, 1:55 PM
Looks like that code is in the
4.4.3
release, just pulled it and the test passes now. Thank you! * Not a Contribution *
a

Ashish Kumar Joy

04/02/2021, 1:57 PM
What u mean by * Not a Contribution *, I am seeing that at end of all your text.
j

James Eschner

04/02/2021, 1:58 PM
Heh, I’m required to do it for legal purposes. From the license: https://github.com/kotest/kotest/blob/2d1a75d6b10c1579ab2b23d60b2180a4ca60cc48/LICENSE#L49 * Not a Contribution *
a

Ashish Kumar Joy

04/02/2021, 2:00 PM
Oh okay
c

christophsturm

04/02/2021, 3:38 PM
why do you think that messages in this slack channel fall under the apache license just because the library that the channel is about is under apache license?
hmm ok the license says so. interesting