https://kotlinlang.org logo
#kotest
Title
# kotest
j

julian

02/04/2023, 9:41 PM
What's the recommendation when wanting to use
checkAll
, or something like it, but when more than 12 values need to be generated at once?
s

sam

02/04/2023, 9:43 PM
Make a PR to add 13, 14, etc 😛
e

Emil Kantis

02/04/2023, 9:46 PM
You could bind several values into a fixture class.. like:
Copy code
data class Fixture(a: Int, b: String // etc)

checkAll(Arb.bind<Fixture>(), [other arbs]) { (a, b), [ other values] -> 
 }
j

julian

02/04/2023, 9:49 PM
Make a PR to add 13, 14, etc 😛
If it won't be rejected on principle alone, I will. Just wouldn't want to do a bunch of work that's rejected for reasons other than implementation choices.
s

sam

02/04/2023, 9:50 PM
It wouldn't be rejected if you just copy n paste the 12 arity one and make a 13 arity one, etc
j

julian

02/04/2023, 9:50 PM
That's exactly what I had in mind...
I want to go up to 22. You game?
Btw, I'm interested in this because we have 22-arity functions in Arrow, which I need to write tests for.
s

sam

02/04/2023, 9:51 PM
yes lets do it
all the way to 22
j

julian

02/04/2023, 9:52 PM
Right on!
@Sam I don't see an existing issue, so I'm going to create one.
s

sam

02/04/2023, 10:01 PM
ok
I'll be releasing 5.5.5 tomorrow so we can include this if it's ready in time
j

julian

02/04/2023, 10:02 PM
Bummer. It's going to be at least a few days before I have this. But thanks for the heads up.
s

sam

02/04/2023, 10:04 PM
Ok well 5.6 will be released shortly after, as a Kotlin 1.8 release
j

julian

02/04/2023, 10:05 PM
Awesome! 🚀
a

Adam S

02/04/2023, 10:29 PM
I notice quite a bit of lag in IntelliJ when the autocomplete for
checkAll()
is loading, which I suspect is related to the large amount of overloads that have lots of generics. Can you make sure that the performance is okay when you try increasing it please?
e

Emil Kantis

02/04/2023, 10:53 PM
Great point adam.. I have had issues with that too 😬
s

sam

02/04/2023, 10:53 PM
I wonder if we could reduce the number of overloads, there's loads that have config/not config etc
j

julian

02/04/2023, 10:56 PM
Can you make sure that the performance is okay when you try increasing it please?
@Adam S Do you have suggestions how to do this? What's the standard to compare to? @sam Could this be a limit on going to 22-arity?
s

sam

02/04/2023, 10:57 PM
We do have a billion overloads, so I would only add more for the ones in this format:
Copy code
suspend fun <A, B> forAll(
   config: PropTestConfig = PropTestConfig(),
   genA: Gen<A>,
   genB: Gen<B>,
   property: suspend PropertyContext.(A, B) -> Boolean
)
And not these ones:
Copy code
suspend fun <A, B> forAll(
   iterations: Int,
   genA: Gen<A>,
   genB: Gen<B>,
   property: suspend PropertyContext.(A, B) -> Boolean
)
And not the ones that infer the types,
Copy code
suspend inline fun <reified A, reified B> forAll(
   crossinline property: PropertyContext.(A, B) -> Boolean
)
If you want to use 20 arbs that's fine, but you can specify them. I think that's a fair tradeoff.
j

julian

02/04/2023, 11:21 PM
Okay, will do @sam. What about the `checkAll`s and `forNone`s? Same pattern for which overloads to not include?
s

sam

02/04/2023, 11:22 PM
yeah
j

julian

02/04/2023, 11:25 PM
And ignore these too?
Copy code
suspend inline fun <reified A, reified B, reified C, reified D, reified E, reified F, reified G, reified H, reified I, reified J, reified K, reified L, reified M> checkAll(
   noinline property: suspend PropertyContext.(A, B, C, D, E, F, G, H, I, J, K, L, M) -> Unit
)
I have a draft PR. Please let me know if all looks good, so I can replicate to remaining arities. Thanks!
s

sam

02/05/2023, 12:30 AM
Yep looks good
j

julian

02/05/2023, 12:31 AM
Cool. Thanks!
@sam Regarding tests for the code I'm adding, I've found
CheckAllExhaustivesIterationTest
,
PropTestConfigConstraintsTest
, and
ForAllExhaustivesIterationTest
, that I need to add tests to. Any others you know of? Thanks!
s

sam

02/07/2023, 7:08 PM
That should be sufficent.
8 Views