Best Kotest code snippet using io.kotest.property.arbitrary.bind.Arb.Companion.bindN
bind.kt
Source:bind.kt
1package io.kotest.property.arbitrary2import io.kotest.property.Arb3import io.kotest.property.Exhaustive4import io.kotest.property.Gen5import io.kotest.property.RTree6import io.kotest.property.RandomSource7import io.kotest.property.Sample8fun <A, B, T> Arb.Companion.bind(9 genA: Gen<A>,10 genB: Gen<B>,11 bindFn: (A, B) -> T12): Arb<T> =13 Arb.bindN(14 genA,15 genB,16 Arb.unit(),17 Arb.unit(),18 Arb.unit(),19 Arb.unit(),20 Arb.unit(),21 Arb.unit(),22 Arb.unit(),23 Arb.unit(),24 Arb.unit(),25 Arb.unit(),26 Arb.unit(),27 Arb.unit()28 ) { a, b, _, _, _, _, _, _, _, _, _, _, _, _ ->29 bindFn(a, b)30 }31fun <A, B, C, T> Arb.Companion.bind(32 genA: Gen<A>,33 genB: Gen<B>,34 genC: Gen<C>,35 bindFn: (A, B, C) -> T36): Arb<T> = Arb.bindN(37 genA,38 genB,39 genC,40 Arb.unit(),41 Arb.unit(),42 Arb.unit(),43 Arb.unit(),44 Arb.unit(),45 Arb.unit(),46 Arb.unit(),47 Arb.unit(),48 Arb.unit(),49 Arb.unit(),50 Arb.unit()51) { a, b, c, _, _, _, _, _, _, _, _, _, _, _ ->52 bindFn(a, b, c)53}54fun <A, B, C, D, T> Arb.Companion.bind(55 genA: Gen<A>,56 genB: Gen<B>,57 genC: Gen<C>,58 genD: Gen<D>,59 bindFn: (A, B, C, D) -> T60): Arb<T> = Arb.bindN(61 genA,62 genB,63 genC,64 genD,65 Arb.unit(),66 Arb.unit(),67 Arb.unit(),68 Arb.unit(),69 Arb.unit(),70 Arb.unit(),71 Arb.unit(),72 Arb.unit(),73 Arb.unit(),74 Arb.unit()75) { a, b, c, d, _, _, _, _, _, _, _, _, _, _ ->76 bindFn(a, b, c, d)77}78fun <A, B, C, D, E, T> Arb.Companion.bind(79 genA: Gen<A>,80 genB: Gen<B>,81 genC: Gen<C>,82 genD: Gen<D>,83 genE: Gen<E>,84 bindFn: (A, B, C, D, E) -> T85): Arb<T> = Arb.bindN(86 genA,87 genB,88 genC,89 genD,90 genE,91 Arb.unit(),92 Arb.unit(),93 Arb.unit(),94 Arb.unit(),95 Arb.unit(),96 Arb.unit(),97 Arb.unit(),98 Arb.unit(),99 Arb.unit()100) { a, b, c, d, e, _, _, _, _, _, _, _, _, _ ->101 bindFn(a, b, c, d, e)102}103fun <A, B, C, D, E, F, T> Arb.Companion.bind(104 genA: Gen<A>,105 genB: Gen<B>,106 genC: Gen<C>,107 genD: Gen<D>,108 genE: Gen<E>,109 genF: Gen<F>,110 bindFn: (A, B, C, D, E, F) -> T111): Arb<T> = Arb.bindN(112 genA,113 genB,114 genC,115 genD,116 genE,117 genF,118 Arb.unit(),119 Arb.unit(),120 Arb.unit(),121 Arb.unit(),122 Arb.unit(),123 Arb.unit(),124 Arb.unit(),125 Arb.unit()126) { a, b, c, d, e, f, _, _, _, _, _, _, _, _ ->127 bindFn(a, b, c, d, e, f)128}129fun <A, B, C, D, E, F, G, T> Arb.Companion.bind(130 genA: Gen<A>,131 genB: Gen<B>,132 genC: Gen<C>,133 genD: Gen<D>,134 genE: Gen<E>,135 genF: Gen<F>,136 genG: Gen<G>,137 bindFn: (A, B, C, D, E, F, G) -> T138): Arb<T> = Arb.bindN(139 genA,140 genB,141 genC,142 genD,143 genE,144 genF,145 genG,146 Arb.unit(),147 Arb.unit(),148 Arb.unit(),149 Arb.unit(),150 Arb.unit(),151 Arb.unit(),152 Arb.unit()153) { a, b, c, d, e, f, g, _, _, _, _, _, _, _ ->154 bindFn(a, b, c, d, e, f, g)155}156fun <A, B, C, D, E, F, G, H, T> Arb.Companion.bind(157 genA: Gen<A>,158 genB: Gen<B>,159 genC: Gen<C>,160 genD: Gen<D>,161 genE: Gen<E>,162 genF: Gen<F>,163 genG: Gen<G>,164 genH: Gen<H>,165 bindFn: (A, B, C, D, E, F, G, H) -> T166): Arb<T> = Arb.bindN(167 genA,168 genB,169 genC,170 genD,171 genE,172 genF,173 genG,174 genH,175 Arb.unit(),176 Arb.unit(),177 Arb.unit(),178 Arb.unit(),179 Arb.unit(),180 Arb.unit()181) { a, b, c, d, e, f, g, h, _, _, _, _, _, _ ->182 bindFn(a, b, c, d, e, f, g, h)183}184fun <A, B, C, D, E, F, G, H, I, T> Arb.Companion.bind(185 genA: Gen<A>,186 genB: Gen<B>,187 genC: Gen<C>,188 genD: Gen<D>,189 genE: Gen<E>,190 genF: Gen<F>,191 genG: Gen<G>,192 genH: Gen<H>,193 genI: Gen<I>,194 bindFn: (A, B, C, D, E, F, G, H, I) -> T195): Arb<T> = Arb.bindN(196 genA,197 genB,198 genC,199 genD,200 genE,201 genF,202 genG,203 genH,204 genI,205 Arb.unit(),206 Arb.unit(),207 Arb.unit(),208 Arb.unit(),209 Arb.unit()210) { a, b, c, d, e, f, g, h, i, _, _, _, _, _ ->211 bindFn(a, b, c, d, e, f, g, h, i)212}213fun <A, B, C, D, E, F, G, H, I, J, T> Arb.Companion.bind(214 genA: Gen<A>,215 genB: Gen<B>,216 genC: Gen<C>,217 genD: Gen<D>,218 genE: Gen<E>,219 genF: Gen<F>,220 genG: Gen<G>,221 genH: Gen<H>,222 genI: Gen<I>,223 genJ: Gen<J>,224 bindFn: (A, B, C, D, E, F, G, H, I, J) -> T225): Arb<T> = Arb.bindN(226 genA,227 genB,228 genC,229 genD,230 genE,231 genF,232 genG,233 genH,234 genI,235 genJ,236 Arb.unit(),237 Arb.unit(),238 Arb.unit(),239 Arb.unit()240) { a, b, c, d, e, f, g, h, i, j, _, _, _, _ ->241 bindFn(a, b, c, d, e, f, g, h, i, j)242}243fun <A, B, C, D, E, F, G, H, I, J, K, T> Arb.Companion.bind(244 genA: Gen<A>,245 genB: Gen<B>,246 genC: Gen<C>,247 genD: Gen<D>,248 genE: Gen<E>,249 genF: Gen<F>,250 genG: Gen<G>,251 genH: Gen<H>,252 genI: Gen<I>,253 genJ: Gen<J>,254 genK: Gen<K>,255 bindFn: (A, B, C, D, E, F, G, H, I, J, K) -> T256): Arb<T> = Arb.bindN(257 genA,258 genB,259 genC,260 genD,261 genE,262 genF,263 genG,264 genH,265 genI,266 genJ,267 genK,268 Arb.unit(),269 Arb.unit(),270 Arb.unit()271) { a, b, c, d, e, f, g, h, i, j, k, _, _, _ ->272 bindFn(a, b, c, d, e, f, g, h, i, j, k)273}274fun <A, B, C, D, E, F, G, H, I, J, K, L, T> Arb.Companion.bind(275 genA: Gen<A>,276 genB: Gen<B>,277 genC: Gen<C>,278 genD: Gen<D>,279 genE: Gen<E>,280 genF: Gen<F>,281 genG: Gen<G>,282 genH: Gen<H>,283 genI: Gen<I>,284 genJ: Gen<J>,285 genK: Gen<K>,286 genL: Gen<L>,287 bindFn: (A, B, C, D, E, F, G, H, I, J, K, L) -> T288): Arb<T> = Arb.bindN(289 genA,290 genB,291 genC,292 genD,293 genE,294 genF,295 genG,296 genH,297 genI,298 genJ,299 genK,300 genL,301 Arb.unit(),302 Arb.unit()303) { a, b, c, d, e, f, g, h, i, j, k, l, _, _ ->304 bindFn(a, b, c, d, e, f, g, h, i, j, k, l)305}306fun <A, B, C, D, E, F, G, H, I, J, K, L, M, T> Arb.Companion.bind(307 genA: Gen<A>,308 genB: Gen<B>,309 genC: Gen<C>,310 genD: Gen<D>,311 genE: Gen<E>,312 genF: Gen<F>,313 genG: Gen<G>,314 genH: Gen<H>,315 genI: Gen<I>,316 genJ: Gen<J>,317 genK: Gen<K>,318 genL: Gen<L>,319 genM: Gen<M>,320 bindFn: (A, B, C, D, E, F, G, H, I, J, K, L, M) -> T321): Arb<T> = Arb.bindN(322 genA,323 genB,324 genC,325 genD,326 genE,327 genF,328 genG,329 genH,330 genI,331 genJ,332 genK,333 genL,334 genM,335 Arb.unit()336) { a, b, c, d, e, f, g, h, i, j, k, l, m, _ ->337 bindFn(a, b, c, d, e, f, g, h, i, j, k, l, m)338}339fun <A, B, C, D, E, F, G, H, I, J, K, L, M, N, T> Arb.Companion.bind(340 genA: Gen<A>,341 genB: Gen<B>,342 genC: Gen<C>,343 genD: Gen<D>,344 genE: Gen<E>,345 genF: Gen<F>,346 genG: Gen<G>,347 genH: Gen<H>,348 genI: Gen<I>,349 genJ: Gen<J>,350 genK: Gen<K>,351 genL: Gen<L>,352 genM: Gen<M>,353 genN: Gen<N>,354 bindFn: (A, B, C, D, E, F, G, H, I, J, K, L, M, N) -> T355): Arb<T> = Arb.bindN(356 genA,357 genB,358 genC,359 genD,360 genE,361 genF,362 genG,363 genH,364 genI,365 genJ,366 genK,367 genL,368 genM,369 genN,370 bindFn371)372internal fun Arb.Companion.unit(): Arb<Unit> = arbitrary { }373internal fun <A, B, C, D, E, F, G, H, I, J, K, L, M, N, T> Arb.Companion.bindN(374 genA: Gen<A>,375 genB: Gen<B>,376 genC: Gen<C>,377 genD: Gen<D>,378 genE: Gen<E>,379 genF: Gen<F>,380 genG: Gen<G>,381 genH: Gen<H>,382 genI: Gen<I>,383 genJ: Gen<J>,384 genK: Gen<K>,385 genL: Gen<L>,386 genM: Gen<M>,387 genN: Gen<N>,388 bindFn: (A, B, C, D, E, F, G, H, I, J, K, L, M, N) -> T,389): Arb<T> {390 fun <S> shrink(tree: RTree<S>): List<RTree<S>> = tree.children.value391 fun combineShrinks(392 a: RTree<A>, b: RTree<B>, c: RTree<C>, d: RTree<D>, e: RTree<E>,393 f: RTree<F>, g: RTree<G>, h: RTree<H>, i: RTree<I>, j: RTree<J>,394 k: RTree<K>, l: RTree<L>, m: RTree<M>, n: RTree<N>395 ): RTree<T> =396 RTree(397 {398 bindFn(399 a.value(), b.value(), c.value(), d.value(), e.value(),400 f.value(), g.value(), h.value(), i.value(), j.value(),401 k.value(), l.value(), m.value(), n.value()402 )403 },404 kotlin.lazy {405 shrink(a).map { combineShrinks(it, b, c, d, e, f, g, h, i, j, k, l, m, n) } +406 shrink(b).map { combineShrinks(a, it, c, d, e, f, g, h, i, j, k, l, m, n) } +407 shrink(c).map { combineShrinks(a, b, it, d, e, f, g, h, i, j, k, l, m, n) } +408 shrink(d).map { combineShrinks(a, b, c, it, e, f, g, h, i, j, k, l, m, n) } +409 shrink(e).map { combineShrinks(a, b, c, d, it, f, g, h, i, j, k, l, m, n) } +410 shrink(f).map { combineShrinks(a, b, c, d, e, it, g, h, i, j, k, l, m, n) } +411 shrink(g).map { combineShrinks(a, b, c, d, e, f, it, h, i, j, k, l, m, n) } +412 shrink(h).map { combineShrinks(a, b, c, d, e, f, g, it, i, j, k, l, m, n) } +413 shrink(i).map { combineShrinks(a, b, c, d, e, f, g, h, it, j, k, l, m, n) } +414 shrink(j).map { combineShrinks(a, b, c, d, e, f, g, h, i, it, k, l, m, n) } +415 shrink(k).map { combineShrinks(a, b, c, d, e, f, g, h, i, j, it, l, m, n) } +416 shrink(l).map { combineShrinks(a, b, c, d, e, f, g, h, i, j, k, it, m, n) } +417 shrink(m).map { combineShrinks(a, b, c, d, e, f, g, h, i, j, k, l, it, n) } +418 shrink(n).map { combineShrinks(a, b, c, d, e, f, g, h, i, j, k, l, m, it) }419 }420 )421 val arbA = genA.toArb()422 val arbB = genB.toArb()423 val arbC = genC.toArb()424 val arbD = genD.toArb()425 val arbE = genE.toArb()426 val arbF = genF.toArb()427 val arbG = genG.toArb()428 val arbH = genH.toArb()429 val arbI = genI.toArb()430 val arbJ = genJ.toArb()431 val arbK = genK.toArb()432 val arbL = genL.toArb()433 val arbM = genM.toArb()434 val arbN = genN.toArb()435 return object : Arb<T>() {436 override fun edgecase(rs: RandomSource): T? {437 return bindFn(438 arbA.edgecase(rs) ?: arbA.next(rs),439 arbB.edgecase(rs) ?: arbB.next(rs),440 arbC.edgecase(rs) ?: arbC.next(rs),441 arbD.edgecase(rs) ?: arbD.next(rs),442 arbE.edgecase(rs) ?: arbE.next(rs),443 arbF.edgecase(rs) ?: arbF.next(rs),444 arbG.edgecase(rs) ?: arbG.next(rs),445 arbH.edgecase(rs) ?: arbH.next(rs),446 arbI.edgecase(rs) ?: arbI.next(rs),447 arbJ.edgecase(rs) ?: arbJ.next(rs),448 arbK.edgecase(rs) ?: arbK.next(rs),449 arbL.edgecase(rs) ?: arbL.next(rs),450 arbM.edgecase(rs) ?: arbM.next(rs),451 arbN.edgecase(rs) ?: arbN.next(rs),452 )453 }454 override fun sample(rs: RandomSource): Sample<T> {455 val (av, ar) = arbA.sample(rs)456 val (bv, br) = arbB.sample(rs)457 val (cv, cr) = arbC.sample(rs)458 val (dv, dr) = arbD.sample(rs)459 val (ev, er) = arbE.sample(rs)460 val (fv, fr) = arbF.sample(rs)461 val (gv, gr) = arbG.sample(rs)462 val (hv, hr) = arbH.sample(rs)463 val (iv, ir) = arbI.sample(rs)464 val (jv, jr) = arbJ.sample(rs)465 val (kv, kr) = arbK.sample(rs)466 val (lv, lr) = arbL.sample(rs)467 val (mv, mr) = arbM.sample(rs)468 val (nv, nr) = arbN.sample(rs)469 return Sample(470 bindFn(av, bv, cv, dv, ev, fv, gv, hv, iv, jv, kv, lv, mv, nv),471 combineShrinks(ar, br, cr, dr, er, fr, gr, hr, ir, jr, kr, lr, mr, nr)472 )473 }474 }475}476fun <A, B> Arb.Companion.bind(arbs: List<Arb<A>>, fn: (List<A>) -> B): Arb<B> = bind(arbs).map(fn)477internal fun <T> Gen<T>.toArb(): Arb<T> = when (this) {478 is Arb -> this479 is Exhaustive -> this.toArb()480}481internal fun <A> Arb.Companion.bind(arbs: List<Arb<A>>): Arb<List<A>> = when (arbs.size) {482 0 -> Arb.constant(emptyList())483 1 -> arbs[0].map { listOf(it) }484 else -> {485 val listOfArbs: List<Arb<List<A>>> = arbs.chunked(14) { el ->486 check(el.size <= 14) { "reached an impossible state" }487 when (el.size) {488 0 -> Arb.constant(emptyList())489 1 -> el[0].map { listOf(it) }490 2 -> Arb.bind(el[0], el[1]) { a, b -> listOf(a, b) }491 3 -> Arb.bind(el[0], el[1], el[2]) { a, b, c -> listOf(a, b, c) }492 4 -> Arb.bind(el[0], el[1], el[2], el[3]) { a, b, c, d -> listOf(a, b, c, d) }493 5 -> Arb.bind(el[0], el[1], el[2], el[3], el[4]) { a, b, c, d, e -> listOf(a, b, c, d, e) }494 6 -> Arb.bind(el[0], el[1], el[2], el[3], el[4], el[5]) { a, b, c, d, e, f ->495 listOf(a, b, c, d, e, f)496 }497 7 -> Arb.bind(el[0], el[1], el[2], el[3], el[4], el[5], el[6]) { a, b, c, d, e, f, g ->498 listOf(a, b, c, d, e, f, g)499 }500 8 -> Arb.bind(el[0], el[1], el[2], el[3], el[4], el[5], el[6], el[7]) { a, b, c, d, e, f, g, h ->501 listOf(a, b, c, d, e, f, g, h)502 }503 9 -> Arb.bind(el[0], el[1], el[2], el[3], el[4], el[5], el[6], el[7], el[8]) { a, b, c, d, e, f, g, h, i ->504 listOf(a, b, c, d, e, f, g, h, i)505 }506 10 -> Arb.bind(507 el[0], el[1], el[2], el[3], el[4],508 el[5], el[6], el[7], el[8], el[9]509 ) { a, b, c, d, e, f, g, h, i, j ->510 listOf(a, b, c, d, e, f, g, h, i, j)511 }512 11 -> Arb.bind(513 el[0], el[1], el[2], el[3], el[4],514 el[5], el[6], el[7], el[8], el[9],515 el[10]516 ) { a, b, c, d, e, f, g, h, i, j, k ->517 listOf(a, b, c, d, e, f, g, h, i, j, k)518 }519 12 -> Arb.bind(520 el[0], el[1], el[2], el[3], el[4],521 el[5], el[6], el[7], el[8], el[9],522 el[10], el[11]523 ) { a, b, c, d, e, f, g, h, i, j, k, l ->524 listOf(a, b, c, d, e, f, g, h, i, j, k, l)525 }526 13 -> Arb.bind(527 el[0], el[1], el[2], el[3], el[4],528 el[5], el[6], el[7], el[8], el[9],529 el[10], el[11], el[12]530 ) { a, b, c, d, e, f, g, h, i, j, k, l, m ->531 listOf(a, b, c, d, e, f, g, h, i, j, k, l, m)532 }533 14 -> Arb.bind(534 el[0], el[1], el[2], el[3], el[4],535 el[5], el[6], el[7], el[8], el[9],536 el[10], el[11], el[12], el[13]537 ) { a, b, c, d, e, f, g, h, i, j, k, l, m, n ->538 listOf(a, b, c, d, e, f, g, h, i, j, k, l, m, n)539 }540 else -> Arb.constant(emptyList())541 }542 }543 Arb.bind(listOfArbs).map { it.flatten() }544 }545}...
zip.kt
Source:zip.kt
1package io.kotest.property.arbitrary2import io.kotest.property.Arb3import io.kotest.property.Gen4fun <A, B, T> Arb.Companion.zip(5 genA: Gen<A>,6 genB: Gen<B>,7 zipFn: (A, B) -> T8): Arb<T> = Arb.bind(genA, genB, zipFn)9fun <A, B, C, T> Arb.Companion.zip(10 genA: Gen<A>,11 genB: Gen<B>,12 genC: Gen<C>,13 zipFn: (A, B, C) -> T14): Arb<T> = Arb.bindN(15 genA,16 genB,17 genC,18 Arb.unit(),19 Arb.unit(),20 Arb.unit(),21 Arb.unit(),22 Arb.unit(),23 Arb.unit(),24 Arb.unit(),25 Arb.unit(),26 Arb.unit(),27 Arb.unit(),28 Arb.unit()29) { a, b, c, _, _, _, _, _, _, _, _, _, _, _ ->30 zipFn(a, b, c)31}32fun <A, B, C, D, T> Arb.Companion.zip(33 genA: Gen<A>,34 genB: Gen<B>,35 genC: Gen<C>,36 genD: Gen<D>,37 zipFn: (A, B, C, D) -> T38): Arb<T> = Arb.bindN(39 genA,40 genB,41 genC,42 genD,43 Arb.unit(),44 Arb.unit(),45 Arb.unit(),46 Arb.unit(),47 Arb.unit(),48 Arb.unit(),49 Arb.unit(),50 Arb.unit(),51 Arb.unit(),52 Arb.unit()53) { a, b, c, d, _, _, _, _, _, _, _, _, _, _ ->54 zipFn(a, b, c, d)55}56fun <A, B, C, D, E, T> Arb.Companion.zip(57 genA: Gen<A>,58 genB: Gen<B>,59 genC: Gen<C>,60 genD: Gen<D>,61 genE: Gen<E>,62 zipFn: (A, B, C, D, E) -> T63): Arb<T> = Arb.bindN(64 genA,65 genB,66 genC,67 genD,68 genE,69 Arb.unit(),70 Arb.unit(),71 Arb.unit(),72 Arb.unit(),73 Arb.unit(),74 Arb.unit(),75 Arb.unit(),76 Arb.unit(),77 Arb.unit()78) { a, b, c, d, e, _, _, _, _, _, _, _, _, _ ->79 zipFn(a, b, c, d, e)80}81fun <A, B, C, D, E, F, T> Arb.Companion.zip(82 genA: Gen<A>,83 genB: Gen<B>,84 genC: Gen<C>,85 genD: Gen<D>,86 genE: Gen<E>,87 genF: Gen<F>,88 zipFn: (A, B, C, D, E, F) -> T89): Arb<T> = Arb.bindN(90 genA,91 genB,92 genC,93 genD,94 genE,95 genF,96 Arb.unit(),97 Arb.unit(),98 Arb.unit(),99 Arb.unit(),100 Arb.unit(),101 Arb.unit(),102 Arb.unit(),103 Arb.unit()104) { a, b, c, d, e, f, _, _, _, _, _, _, _, _ ->105 zipFn(a, b, c, d, e, f)106}107fun <A, B, C, D, E, F, G, T> Arb.Companion.zip(108 genA: Gen<A>,109 genB: Gen<B>,110 genC: Gen<C>,111 genD: Gen<D>,112 genE: Gen<E>,113 genF: Gen<F>,114 genG: Gen<G>,115 zipFn: (A, B, C, D, E, F, G) -> T116): Arb<T> = Arb.bindN(117 genA,118 genB,119 genC,120 genD,121 genE,122 genF,123 genG,124 Arb.unit(),125 Arb.unit(),126 Arb.unit(),127 Arb.unit(),128 Arb.unit(),129 Arb.unit(),130 Arb.unit()131) { a, b, c, d, e, f, g, _, _, _, _, _, _, _ ->132 zipFn(a, b, c, d, e, f, g)133}134fun <A, B, C, D, E, F, G, H, T> Arb.Companion.zip(135 genA: Gen<A>,136 genB: Gen<B>,137 genC: Gen<C>,138 genD: Gen<D>,139 genE: Gen<E>,140 genF: Gen<F>,141 genG: Gen<G>,142 genH: Gen<H>,143 zipFn: (A, B, C, D, E, F, G, H) -> T144): Arb<T> = Arb.bindN(145 genA,146 genB,147 genC,148 genD,149 genE,150 genF,151 genG,152 genH,153 Arb.unit(),154 Arb.unit(),155 Arb.unit(),156 Arb.unit(),157 Arb.unit(),158 Arb.unit()159) { a, b, c, d, e, f, g, h, _, _, _, _, _, _ ->160 zipFn(a, b, c, d, e, f, g, h)161}162fun <A, B, C, D, E, F, G, H, I, T> Arb.Companion.zip(163 genA: Gen<A>,164 genB: Gen<B>,165 genC: Gen<C>,166 genD: Gen<D>,167 genE: Gen<E>,168 genF: Gen<F>,169 genG: Gen<G>,170 genH: Gen<H>,171 genI: Gen<I>,172 zipFn: (A, B, C, D, E, F, G, H, I) -> T173): Arb<T> = Arb.bindN(174 genA,175 genB,176 genC,177 genD,178 genE,179 genF,180 genG,181 genH,182 genI,183 Arb.unit(),184 Arb.unit(),185 Arb.unit(),186 Arb.unit(),187 Arb.unit()188) { a, b, c, d, e, f, g, h, i, _, _, _, _, _ ->189 zipFn(a, b, c, d, e, f, g, h, i)190}191fun <A, B, C, D, E, F, G, H, I, J, T> Arb.Companion.zip(192 genA: Gen<A>,193 genB: Gen<B>,194 genC: Gen<C>,195 genD: Gen<D>,196 genE: Gen<E>,197 genF: Gen<F>,198 genG: Gen<G>,199 genH: Gen<H>,200 genI: Gen<I>,201 genJ: Gen<J>,202 zipFn: (A, B, C, D, E, F, G, H, I, J) -> T203): Arb<T> = Arb.bindN(204 genA,205 genB,206 genC,207 genD,208 genE,209 genF,210 genG,211 genH,212 genI,213 genJ,214 Arb.unit(),215 Arb.unit(),216 Arb.unit(),217 Arb.unit()218) { a, b, c, d, e, f, g, h, i, j, _, _, _, _ ->219 zipFn(a, b, c, d, e, f, g, h, i, j)220}221fun <A, B, C, D, E, F, G, H, I, J, K, T> Arb.Companion.zip(222 genA: Gen<A>,223 genB: Gen<B>,224 genC: Gen<C>,225 genD: Gen<D>,226 genE: Gen<E>,227 genF: Gen<F>,228 genG: Gen<G>,229 genH: Gen<H>,230 genI: Gen<I>,231 genJ: Gen<J>,232 genK: Gen<K>,233 zipFn: (A, B, C, D, E, F, G, H, I, J, K) -> T234): Arb<T> = Arb.bindN(235 genA,236 genB,237 genC,238 genD,239 genE,240 genF,241 genG,242 genH,243 genI,244 genJ,245 genK,246 Arb.unit(),247 Arb.unit(),248 Arb.unit()249) { a, b, c, d, e, f, g, h, i, j, k, _, _, _ ->250 zipFn(a, b, c, d, e, f, g, h, i, j, k)251}252fun <A, B, C, D, E, F, G, H, I, J, K, L, T> Arb.Companion.zip(253 genA: Gen<A>,254 genB: Gen<B>,255 genC: Gen<C>,256 genD: Gen<D>,257 genE: Gen<E>,258 genF: Gen<F>,259 genG: Gen<G>,260 genH: Gen<H>,261 genI: Gen<I>,262 genJ: Gen<J>,263 genK: Gen<K>,264 genL: Gen<L>,265 zipFn: (A, B, C, D, E, F, G, H, I, J, K, L) -> T266): Arb<T> = Arb.bindN(267 genA,268 genB,269 genC,270 genD,271 genE,272 genF,273 genG,274 genH,275 genI,276 genJ,277 genK,278 genL,279 Arb.unit(),280 Arb.unit()281) { a, b, c, d, e, f, g, h, i, j, k, l, _, _ ->282 zipFn(a, b, c, d, e, f, g, h, i, j, k, l)283}284fun <A, B, C, D, E, F, G, H, I, J, K, L, M, T> Arb.Companion.zip(285 genA: Gen<A>,286 genB: Gen<B>,287 genC: Gen<C>,288 genD: Gen<D>,289 genE: Gen<E>,290 genF: Gen<F>,291 genG: Gen<G>,292 genH: Gen<H>,293 genI: Gen<I>,294 genJ: Gen<J>,295 genK: Gen<K>,296 genL: Gen<L>,297 genM: Gen<M>,298 zipFn: (A, B, C, D, E, F, G, H, I, J, K, L, M) -> T299): Arb<T> = Arb.bindN(300 genA,301 genB,302 genC,303 genD,304 genE,305 genF,306 genG,307 genH,308 genI,309 genJ,310 genK,311 genL,312 genM,313 Arb.unit()314) { a, b, c, d, e, f, g, h, i, j, k, l, m, _ ->315 zipFn(a, b, c, d, e, f, g, h, i, j, k, l, m)316}317fun <A, B, C, D, E, F, G, H, I, J, K, L, M, N, T> Arb.Companion.zip(318 genA: Gen<A>,319 genB: Gen<B>,320 genC: Gen<C>,321 genD: Gen<D>,322 genE: Gen<E>,323 genF: Gen<F>,324 genG: Gen<G>,325 genH: Gen<H>,326 genI: Gen<I>,327 genJ: Gen<J>,328 genK: Gen<K>,329 genL: Gen<L>,330 genM: Gen<M>,331 genN: Gen<N>,332 zipFn: (A, B, C, D, E, F, G, H, I, J, K, L, M, N) -> T333): Arb<T> = Arb.bindN(334 genA,335 genB,336 genC,337 genD,338 genE,339 genF,340 genG,341 genH,342 genI,343 genJ,344 genK,345 genL,346 genM,347 genN,348 zipFn349)350fun <A, B> Arb.Companion.zip(arbs: List<Arb<A>>, fn: (List<A>) -> B): Arb<B> = bind(arbs).map(fn)...
Arb.Companion.bindN
Using AI Code Generation
1val intArb = Arb.int(1..100)2val stringArb = Arb.string(1..100, Arb.alpha())3val arb = intArb.bindN(stringArb) { i: Int, s: String -> i to s }4arb.take(10).toList()5val intArb = Arb.int(1..100)6val stringArb = Arb.string(1..100, Arb.alpha())7val booleanArb = Arb.bool()8val arb = intArb.bindN(stringArb, booleanArb) { i: Int, s: String, b: Boolean -> i to s to b }9arb.take(10).toList()10val intArb = Arb.int(1..100)11val stringArb = Arb.string(1..100, Arb.alpha())12val booleanArb = Arb.bool()13val charArb = Arb.char()14val arb = intArb.bindN(stringArb, booleanArb, charArb) { i: Int, s: String, b: Boolean, c: Char -> i to s to b to c }15arb.take(10).toList()16val intArb = Arb.int(1..100)17val stringArb = Arb.string(1..100, Arb.alpha())18val booleanArb = Arb.bool()19val charArb = Arb.char()20val longArb = Arb.long(1..100)21val arb = intArb.bindN(stringArb, booleanArb, charArb, longArb) { i: Int, s: String, b: Boolean, c: Char, l: Long -> i to s to b to c to l }22arb.take(10).toList()
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!