Ran into an issue using `Arb.bigDecimal()` . Code:...
# kotest
j
Ran into an issue using
Arb.bigDecimal()
. Code:
Copy 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
        }
    }
})
Copy code
~~~ 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
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
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
What u mean by * Not a Contribution *, I am seeing that at end of all your text.
j
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
Oh okay
c
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
132 Views