This may be more "kotlin" than "kotest", but here ...
# kotest
m
This may be more "kotlin" than "kotest", but here goes. My (hopefully obvious) custom generator
Copy code
val circleExh = cartesian(
    Exhaustive.collection(listOf(start)),
    Exhaustive.collection(listOf(0..360)),
    Exhaustive.collection(listOf(400)),
    Exhaustive.collection(listOf("left", "right")),
    Exhaustive.collection(listOf(90, 180, 270, 360)),
    Exhaustive.collection(listOf(Pair(400, 300), Pair(200, 300), Pair(300, 400), Pair(300, 200),
            Pair(400, 200), Pair(400, 400), Pair(200, 400), Pair(200, 200))),
    Exhaustive.collection(listOf(5))
) { start: Points, startAngle: Int, radius: Int, direction: String, turn: Int, centre: Pair<Int, Int>, duration: Int ->
       Circle(listOf(start, startAngle, radius, turn, centre, direction, duration)) }
fails lint "because of receiver type mismatch". Why? I couldn't find any documentation about "cartesian" but found it in StackExchange, but it seems to be a thing. My exhaustive collections of only one item seemed to be necessary, but the error statement was the same when I just put the single item in the Circle function call definition. How do I fix this?
1
c
What's the entire error?
e
Exhaustive.collection(listOf(0..360))
will return an Exhaustive<IntRange>, not Exhaustive<Int> as your code requires. You can write it as
Exhaustive.ints(0..360)
instead
Exhaustive.collection(listOf(90, 180, 270, 360))
can be simplified as
Exhaustive.of(90, 180, 270, 360)
m
Coo, that's interesting @Emil Kantis, thanks, I hadn't realised. I've changed the range into "ints" and everything else into "of" (overkill?) I get the same error. @CLOVIS the error is huge! It' says
Unresolved reference. None of the following candidates is applicable because of receiver type mismatch:
public fun <A, B, C> Exhaustive.Companion.cartesian(a: Exhaustive<TypeVariable(A)>, b: Exhaustive<TypeVariable(B)>, f: (TypeVariable(A), TypeVariable(B)) → TypeVariable(C)): Exhaustive<TypeVariable(C)> defined in io.kotest.property.exhaustive
With every possibility up to 13 types.
e
Sounds like some types mismatch still.. What does your Circle constructor look like?
m
Copy code
class Circle(shapeParams: List<Any>): Shaping() { }
e
And
start
is a
Points
?
m
Yup
I think the extra bits you need are
Copy code
val start = Points()
start.widthPos = 300F
start.lengthPos = 300F
Those are the only two properties needed in Points
I used a FunSpec, tho' I don't s'pose that's important (?)
e
All green for me 🫠
Spec style doesn't matter
You might have some import that screws things up?
m
Ahah! That is what I was missing, "Exhaustive" in front of "cartesian" 😕
Thank you!. The lack of documentation makes things a bit difficult for those of us of very little brain 😞😄
l
I think those are hard to grasp mathematical concepts converted to a programming language. Once your little brain gets its hand on it it will become easier 🙂
Suggestions to the docs are much appreciated anyway
🤔 1