How to use iterations method of io.kotest.property.Constraints class

Best Kotest code snippet using io.kotest.property.Constraints.iterations

proptest.kt

Source:proptest.kt Github

copy

Full Screen

...14 property: suspend PropertyContext.(A) -> Unit15): PropertyContext {16 config.checkFailOnSeed()17 val constraints = config.constraints18 ?: config.iterations?.let { Constraints.iterations(it) }19 ?: Constraints.iterations(PropertyTesting.defaultIterationCount)20 val context = PropertyContext()21 val random = createRandom(config)22 when (genA) {23 is Arb -> {24 genA.generate(random, config.edgeConfig)25 .takeWhile { constraints.evaluate() }26 .forEach { a ->27 val shrinkfn = shrinkfn(a, property, config.shrinkingMode)28 config.listeners.forEach { it.beforeTest() }29 test(30 context,31 config,32 shrinkfn,33 listOf(a.value),34 listOf(genA.classifier),35 random.seed36 ) {37 context.property(a.value)38 }39 config.listeners.forEach { it.afterTest() }40 }41 }42 is Exhaustive -> {43 genA.values.forEach { a ->44 config.listeners.forEach { it.beforeTest() }45 test(46 context,47 config,48 { emptyList() },49 listOf(a),50 listOf(genA.classifier),51 random.seed52 ) {53 context.property(a)54 }55 config.listeners.forEach { it.afterTest() }56 }57 }58 }59 context.outputClassifications(1, config, random.seed)60 context.checkMaxSuccess(config, random.seed)61 return context62}63suspend fun <A, B> proptest(64 genA: Gen<A>,65 genB: Gen<B>,66 config: PropTestConfig,67 property: suspend PropertyContext.(A, B) -> Unit68): PropertyContext {69 config.checkFailOnSeed()70 val constraints = config.constraints71 ?: config.iterations?.let { Constraints.iterations(it) }72 ?: Constraints.iterations(PropertyTesting.defaultIterationCount)73 val context = PropertyContext()74 val random = createRandom(config)75 if (genA is Exhaustive && genB is Exhaustive) {76 genA.values.forEach { a ->77 genB.values.forEach { b ->78 config.listeners.forEach { it.beforeTest() }79 test(80 context,81 config,82 { emptyList() },83 listOf(a, b),84 listOf(genA.classifier, genB.classifier),85 random.seed86 ) {87 context.property(a, b)88 }89 config.listeners.forEach { it.afterTest() }90 }91 }92 } else {93 genA.generate(random, config.edgeConfig)94 .zip(genB.generate(random, config.edgeConfig))95 .takeWhile { constraints.evaluate() }96 .forEach { (a, b) ->97 val shrinkfn = shrinkfn(a, b, property, config.shrinkingMode)98 config.listeners.forEach { it.beforeTest() }99 test(100 context,101 config,102 shrinkfn,103 listOf(a.value, b.value),104 listOf(genA.classifier, genB.classifier),105 random.seed106 ) {107 context.property(a.value, b.value)108 }109 config.listeners.forEach { it.afterTest() }110 }111 }112 context.outputClassifications(2, config, random.seed)113 context.checkMaxSuccess(config, random.seed)114 return context115}116suspend fun <A, B, C> proptest(117 genA: Gen<A>,118 genB: Gen<B>,119 genC: Gen<C>,120 config: PropTestConfig,121 property: suspend PropertyContext.(A, B, C) -> Unit122): PropertyContext {123 config.checkFailOnSeed()124 val constraints = config.constraints125 ?: config.iterations?.let { Constraints.iterations(it) }126 ?: Constraints.iterations(PropertyTesting.defaultIterationCount)127 val context = PropertyContext()128 val random = createRandom(config)129 if (genA is Exhaustive && genB is Exhaustive && genC is Exhaustive) {130 genA.values.forEach { a ->131 genB.values.forEach { b ->132 genC.values.forEach { c ->133 config.listeners.forEach { it.beforeTest() }134 test(135 context,136 config,137 { emptyList() },138 listOf(a, b, c),139 listOf(genA.classifier, genB.classifier, genC.classifier),140 random.seed141 ) {142 context.property(a, b, c)143 }144 config.listeners.forEach { it.afterTest() }145 }146 }147 }148 } else {149 genA.generate(random, config.edgeConfig)150 .zip(genB.generate(random, config.edgeConfig))151 .zip(genC.generate(random, config.edgeConfig))152 .takeWhile { constraints.evaluate() }153 .forEach { (ab, c) ->154 val (a, b) = ab155 val shrinkfn = shrinkfn(a, b, c, property, config.shrinkingMode)156 config.listeners.forEach { it.beforeTest() }157 test(158 context,159 config,160 shrinkfn,161 listOf(a.value, b.value, c.value),162 listOf(genA.classifier, genB.classifier, genC.classifier),163 random.seed164 ) {165 context.property(a.value, b.value, c.value)166 }167 config.listeners.forEach { it.afterTest() }168 }169 }170 context.outputClassifications(3, config, random.seed)171 context.checkMaxSuccess(config, random.seed)172 return context173}174suspend fun <A, B, C, D> proptest(175 genA: Gen<A>,176 genB: Gen<B>,177 genC: Gen<C>,178 genD: Gen<D>,179 config: PropTestConfig,180 property: suspend PropertyContext.(A, B, C, D) -> Unit181): PropertyContext {182 config.checkFailOnSeed()183 val constraints = config.constraints184 ?: config.iterations?.let { Constraints.iterations(it) }185 ?: Constraints.iterations(PropertyTesting.defaultIterationCount)186 val context = PropertyContext()187 val random = createRandom(config)188 if (genA is Exhaustive && genB is Exhaustive && genC is Exhaustive && genD is Exhaustive) {189 genA.values.forEach { a ->190 genB.values.forEach { b ->191 genC.values.forEach { c ->192 genD.values.forEach { d ->193 config.listeners.forEach { it.beforeTest() }194 test(195 context, config, { emptyList() }, listOf(a, b, c, d),196 listOf(genA.classifier, genB.classifier, genC.classifier, genD.classifier), random.seed197 ) {198 context.property(a, b, c, d)199 }200 config.listeners.forEach { it.afterTest() }201 }202 }203 }204 }205 } else {206 genA.generate(random, config.edgeConfig)207 .zip(genB.generate(random, config.edgeConfig))208 .zip(genC.generate(random, config.edgeConfig))209 .zip(genD.generate(random, config.edgeConfig))210 .takeWhile { constraints.evaluate() }211 .forEach { (abc, d) ->212 val (ab, c) = abc213 val (a, b) = ab214 val shrinkfn = shrinkfn(a, b, c, d, property, config.shrinkingMode)215 config.listeners.forEach { it.beforeTest() }216 test(217 context, config, shrinkfn,218 listOf(a.value, b.value, c.value, d.value),219 listOf(genA.classifier, genB.classifier, genC.classifier, genD.classifier),220 random.seed221 ) {222 context.property(a.value, b.value, c.value, d.value)223 }224 config.listeners.forEach { it.afterTest() }225 }226 }227 context.outputClassifications(4, config, random.seed)228 context.checkMaxSuccess(config, random.seed)229 return context230}231suspend fun <A, B, C, D, E> proptest(232 genA: Gen<A>,233 genB: Gen<B>,234 genC: Gen<C>,235 genD: Gen<D>,236 genE: Gen<E>,237 config: PropTestConfig,238 property: suspend PropertyContext.(A, B, C, D, E) -> Unit239): PropertyContext {240 config.checkFailOnSeed()241 val constraints = config.constraints242 ?: config.iterations?.let { Constraints.iterations(it) }243 ?: Constraints.iterations(PropertyTesting.defaultIterationCount)244 val context = PropertyContext()245 val random = createRandom(config)246 if (genA is Exhaustive && genB is Exhaustive && genC is Exhaustive && genD is Exhaustive && genE is Exhaustive) {247 genA.values.forEach { a ->248 genB.values.forEach { b ->249 genC.values.forEach { c ->250 genD.values.forEach { d ->251 genE.values.forEach { e ->252 config.listeners.forEach { it.beforeTest() }253 test(254 context,255 config,256 { emptyList() },257 listOf(a, b, c, d, e),258 listOf(259 genA.classifier,260 genB.classifier,261 genC.classifier,262 genD.classifier,263 genE.classifier,264 ),265 random.seed266 ) {267 context.property(a, b, c, d, e)268 }269 config.listeners.forEach { it.afterTest() }270 }271 }272 }273 }274 }275 } else {276 genA.generate(random, config.edgeConfig)277 .zip(genB.generate(random, config.edgeConfig))278 .zip(genC.generate(random, config.edgeConfig))279 .zip(genD.generate(random, config.edgeConfig))280 .zip(genE.generate(random, config.edgeConfig))281 .takeWhile { constraints.evaluate() }282 .forEach { (abcd, e) ->283 val (abc, d) = abcd284 val (ab, c) = abc285 val (a, b) = ab286 val shrinkfn = shrinkfn(a, b, c, d, e, property, config.shrinkingMode)287 config.listeners.forEach { it.beforeTest() }288 test(289 context,290 config,291 shrinkfn,292 listOf(a.value, b.value, c.value, d.value, e.value),293 listOf(294 genA.classifier,295 genB.classifier,296 genC.classifier,297 genD.classifier,298 genE.classifier,299 ),300 random.seed301 ) {302 context.property(a.value, b.value, c.value, d.value, e.value)303 }304 config.listeners.forEach { it.afterTest() }305 }306 }307 context.outputClassifications(5, config, random.seed)308 context.checkMaxSuccess(config, random.seed)309 return context310}311suspend fun <A, B, C, D, E, F> proptest(312 genA: Gen<A>,313 genB: Gen<B>,314 genC: Gen<C>,315 genD: Gen<D>,316 genE: Gen<E>,317 genF: Gen<F>,318 config: PropTestConfig,319 property: suspend PropertyContext.(A, B, C, D, E, F) -> Unit320): PropertyContext {321 config.checkFailOnSeed()322 val constraints = config.constraints323 ?: config.iterations?.let { Constraints.iterations(it) }324 ?: Constraints.iterations(PropertyTesting.defaultIterationCount)325 val context = PropertyContext()326 val random = createRandom(config)327 genA.generate(random, config.edgeConfig)328 .zip(genB.generate(random, config.edgeConfig))329 .zip(genC.generate(random, config.edgeConfig))330 .zip(genD.generate(random, config.edgeConfig))331 .zip(genE.generate(random, config.edgeConfig))332 .zip(genF.generate(random, config.edgeConfig))333 .takeWhile { constraints.evaluate() }334 .forEach { (abcde, f) ->335 val (abcd, e) = abcde336 val (abc, d) = abcd337 val (ab, c) = abc338 val (a, b) = ab339 val shrinkfn = shrinkfn(a, b, c, d, e, f, property, config.shrinkingMode)340 config.listeners.forEach { it.beforeTest() }341 test(342 context,343 config,344 shrinkfn,345 listOf(a.value, b.value, c.value, d.value, e.value, f.value),346 listOf(347 genA.classifier,348 genB.classifier,349 genC.classifier,350 genD.classifier,351 genE.classifier,352 genF.classifier,353 ),354 random.seed355 ) {356 context.property(a.value, b.value, c.value, d.value, e.value, f.value)357 }358 config.listeners.forEach { it.afterTest() }359 }360 context.outputClassifications(6, config, random.seed)361 context.checkMaxSuccess(config, random.seed)362 return context363}364suspend fun <A, B, C, D, E, F, G> proptest(365 genA: Gen<A>,366 genB: Gen<B>,367 genC: Gen<C>,368 genD: Gen<D>,369 genE: Gen<E>,370 genF: Gen<F>,371 genG: Gen<G>,372 config: PropTestConfig,373 property: suspend PropertyContext.(A, B, C, D, E, F, G) -> Unit374): PropertyContext {375 config.checkFailOnSeed()376 val constraints = config.constraints377 ?: config.iterations?.let { Constraints.iterations(it) }378 ?: Constraints.iterations(PropertyTesting.defaultIterationCount)379 val context = PropertyContext()380 val random = createRandom(config)381 genA.generate(random, config.edgeConfig)382 .zip(genB.generate(random, config.edgeConfig))383 .zip(genC.generate(random, config.edgeConfig))384 .zip(genD.generate(random, config.edgeConfig))385 .zip(genE.generate(random, config.edgeConfig))386 .zip(genF.generate(random, config.edgeConfig))387 .zip(genG.generate(random, config.edgeConfig))388 .takeWhile { constraints.evaluate() }389 .forEach { (abcdef, g) ->390 val (abcde, f) = abcdef391 val (abcd, e) = abcde392 val (abc, d) = abcd393 val (ab, c) = abc394 val (a, b) = ab395 val shrinkfn = shrinkfn(a, b, c, d, e, f, g, property, config.shrinkingMode)396 config.listeners.forEach { it.beforeTest() }397 test(398 context,399 config,400 shrinkfn,401 listOf(a.value, b.value, c.value, d.value, e.value, f.value, g.value),402 listOf(403 genA.classifier,404 genB.classifier,405 genC.classifier,406 genD.classifier,407 genE.classifier,408 genF.classifier,409 genG.classifier410 ),411 random.seed412 ) {413 context.property(a.value, b.value, c.value, d.value, e.value, f.value, g.value)414 }415 config.listeners.forEach { it.afterTest() }416 }417 context.outputClassifications(7, config, random.seed)418 context.checkMaxSuccess(config, random.seed)419 return context420}421suspend fun <A, B, C, D, E, F, G, H> proptest(422 genA: Gen<A>,423 genB: Gen<B>,424 genC: Gen<C>,425 genD: Gen<D>,426 genE: Gen<E>,427 genF: Gen<F>,428 genG: Gen<G>,429 genH: Gen<H>,430 config: PropTestConfig,431 property: suspend PropertyContext.(A, B, C, D, E, F, G, H) -> Unit432): PropertyContext {433 config.checkFailOnSeed()434 val constraints = config.constraints435 ?: config.iterations?.let { Constraints.iterations(it) }436 ?: Constraints.iterations(PropertyTesting.defaultIterationCount)437 val context = PropertyContext()438 val random = createRandom(config)439 genA.generate(random, config.edgeConfig)440 .zip(genB.generate(random, config.edgeConfig))441 .zip(genC.generate(random, config.edgeConfig))442 .zip(genD.generate(random, config.edgeConfig))443 .zip(genE.generate(random, config.edgeConfig))444 .zip(genF.generate(random, config.edgeConfig))445 .zip(genG.generate(random, config.edgeConfig))446 .zip(genH.generate(random, config.edgeConfig))447 .takeWhile { constraints.evaluate() }448 .forEach { (abcdefg, h) ->449 val (abcdef, g) = abcdefg450 val (abcde, f) = abcdef451 val (abcd, e) = abcde452 val (abc, d) = abcd453 val (ab, c) = abc454 val (a, b) = ab455 val shrinkfn = shrinkfn(a, b, c, d, e, f, g, h, property, config.shrinkingMode)456 config.listeners.forEach { it.beforeTest() }457 test(458 context,459 config,460 shrinkfn,461 listOf(a.value, b.value, c.value, d.value, e.value, f.value, g.value, h.value),462 listOf(463 genA.classifier,464 genB.classifier,465 genC.classifier,466 genD.classifier,467 genE.classifier,468 genF.classifier,469 genG.classifier,470 genH.classifier471 ),472 random.seed473 ) {474 context.property(a.value, b.value, c.value, d.value, e.value, f.value, g.value, h.value)475 }476 config.listeners.forEach { it.afterTest() }477 }478 context.outputClassifications(8, config, random.seed)479 context.checkMaxSuccess(config, random.seed)480 return context481}482suspend fun <A, B, C, D, E, F, G, H, I> proptest(483 genA: Gen<A>,484 genB: Gen<B>,485 genC: Gen<C>,486 genD: Gen<D>,487 genE: Gen<E>,488 genF: Gen<F>,489 genG: Gen<G>,490 genH: Gen<H>,491 genI: Gen<I>,492 config: PropTestConfig,493 property: suspend PropertyContext.(A, B, C, D, E, F, G, H, I) -> Unit494): PropertyContext {495 config.checkFailOnSeed()496 val constraints = config.constraints497 ?: config.iterations?.let { Constraints.iterations(it) }498 ?: Constraints.iterations(PropertyTesting.defaultIterationCount)499 val context = PropertyContext()500 val random = createRandom(config)501 genA.generate(random, config.edgeConfig)502 .zip(genB.generate(random, config.edgeConfig))503 .zip(genC.generate(random, config.edgeConfig))504 .zip(genD.generate(random, config.edgeConfig))505 .zip(genE.generate(random, config.edgeConfig))506 .zip(genF.generate(random, config.edgeConfig))507 .zip(genG.generate(random, config.edgeConfig))508 .zip(genH.generate(random, config.edgeConfig))509 .zip(genI.generate(random, config.edgeConfig))510 .takeWhile { constraints.evaluate() }511 .forEach { (abcdefgh, i) ->512 val (abcdefg, h) = abcdefgh513 val (abcdef, g) = abcdefg514 val (abcde, f) = abcdef515 val (abcd, e) = abcde516 val (abc, d) = abcd517 val (ab, c) = abc518 val (a, b) = ab519 val shrinkfn = shrinkfn(a, b, c, d, e, f, g, h, i, property, config.shrinkingMode)520 config.listeners.forEach { it.beforeTest() }521 test(522 context,523 config,524 shrinkfn,525 listOf(a.value, b.value, c.value, d.value, e.value, f.value, g.value, h.value, i.value),526 listOf(527 genA.classifier,528 genB.classifier,529 genC.classifier,530 genD.classifier,531 genE.classifier,532 genF.classifier,533 genG.classifier,534 genH.classifier,535 genI.classifier536 ),537 random.seed538 ) {539 context.property(a.value, b.value, c.value, d.value, e.value, f.value, g.value, h.value, i.value)540 }541 config.listeners.forEach { it.afterTest() }542 }543 context.outputClassifications(9, config, random.seed)544 context.checkMaxSuccess(config, random.seed)545 return context546}547suspend fun <A, B, C, D, E, F, G, H, I, J> proptest(548 genA: Gen<A>,549 genB: Gen<B>,550 genC: Gen<C>,551 genD: Gen<D>,552 genE: Gen<E>,553 genF: Gen<F>,554 genG: Gen<G>,555 genH: Gen<H>,556 genI: Gen<I>,557 genJ: Gen<J>,558 config: PropTestConfig,559 property: suspend PropertyContext.(A, B, C, D, E, F, G, H, I, J) -> Unit560): PropertyContext {561 config.checkFailOnSeed()562 val constraints = config.constraints563 ?: config.iterations?.let { Constraints.iterations(it) }564 ?: Constraints.iterations(PropertyTesting.defaultIterationCount)565 val context = PropertyContext()566 val random = createRandom(config)567 genA.generate(random, config.edgeConfig)568 .zip(genB.generate(random, config.edgeConfig))569 .zip(genC.generate(random, config.edgeConfig))570 .zip(genD.generate(random, config.edgeConfig))571 .zip(genE.generate(random, config.edgeConfig))572 .zip(genF.generate(random, config.edgeConfig))573 .zip(genG.generate(random, config.edgeConfig))574 .zip(genH.generate(random, config.edgeConfig))575 .zip(genI.generate(random, config.edgeConfig))576 .zip(genJ.generate(random, config.edgeConfig))577 .takeWhile { constraints.evaluate() }578 .forEach { (abcdefghi, j) ->579 val (abcdefgh, i) = abcdefghi580 val (abcdefg, h) = abcdefgh581 val (abcdef, g) = abcdefg582 val (abcde, f) = abcdef583 val (abcd, e) = abcde584 val (abc, d) = abcd585 val (ab, c) = abc586 val (a, b) = ab587 val shrinkfn = shrinkfn(a, b, c, d, e, f, g, h, i, j, property, config.shrinkingMode)588 config.listeners.forEach { it.beforeTest() }589 test(590 context,591 config,592 shrinkfn,593 listOf(a.value, b.value, c.value, d.value, e.value, f.value, g.value, h.value, i.value, j.value),594 listOf(595 genA.classifier,596 genB.classifier,597 genC.classifier,598 genD.classifier,599 genE.classifier,600 genF.classifier,601 genG.classifier,602 genH.classifier,603 genI.classifier,604 genJ.classifier605 ),606 random.seed607 ) {608 context.property(a.value, b.value, c.value, d.value, e.value, f.value, g.value, h.value, i.value, j.value)609 }610 config.listeners.forEach { it.afterTest() }611 }612 context.outputClassifications(10, config, random.seed)613 context.checkMaxSuccess(config, random.seed)614 return context615}616suspend fun <A, B, C, D, E, F, G, H, I, J, K> proptest(617 genA: Gen<A>,618 genB: Gen<B>,619 genC: Gen<C>,620 genD: Gen<D>,621 genE: Gen<E>,622 genF: Gen<F>,623 genG: Gen<G>,624 genH: Gen<H>,625 genI: Gen<I>,626 genJ: Gen<J>,627 genK: Gen<K>,628 config: PropTestConfig,629 property: suspend PropertyContext.(A, B, C, D, E, F, G, H, I, J, K) -> Unit630): PropertyContext {631 config.checkFailOnSeed()632 val constraints = config.constraints633 ?: config.iterations?.let { Constraints.iterations(it) }634 ?: Constraints.iterations(PropertyTesting.defaultIterationCount)635 val context = PropertyContext()636 val random = createRandom(config)637 genA.generate(random, config.edgeConfig)638 .zip(genB.generate(random, config.edgeConfig))639 .zip(genC.generate(random, config.edgeConfig))640 .zip(genD.generate(random, config.edgeConfig))641 .zip(genE.generate(random, config.edgeConfig))642 .zip(genF.generate(random, config.edgeConfig))643 .zip(genG.generate(random, config.edgeConfig))644 .zip(genH.generate(random, config.edgeConfig))645 .zip(genI.generate(random, config.edgeConfig))646 .zip(genJ.generate(random, config.edgeConfig))647 .zip(genK.generate(random, config.edgeConfig))648 .takeWhile { constraints.evaluate() }649 .forEach { (abcdefghij, k) ->650 val (abcdefghi, j) = abcdefghij651 val (abcdefgh, i) = abcdefghi652 val (abcdefg, h) = abcdefgh653 val (abcdef, g) = abcdefg654 val (abcde, f) = abcdef655 val (abcd, e) = abcde656 val (abc, d) = abcd657 val (ab, c) = abc658 val (a, b) = ab659 val shrinkfn = shrinkfn(a, b, c, d, e, f, g, h, i, j, k, property, config.shrinkingMode)660 config.listeners.forEach { it.beforeTest() }661 test(662 context,663 config,664 shrinkfn,665 listOf(a.value, b.value, c.value, d.value, e.value, f.value, g.value, h.value, i.value, j.value, k.value),666 listOf(667 genA.classifier,668 genB.classifier,669 genC.classifier,670 genD.classifier,671 genE.classifier,672 genF.classifier,673 genG.classifier,674 genH.classifier,675 genI.classifier,676 genJ.classifier,677 genK.classifier678 ),679 random.seed680 ) {681 context.property(682 a.value,683 b.value,684 c.value,685 d.value,686 e.value,687 f.value,688 g.value,689 h.value,690 i.value,691 j.value,692 k.value693 )694 }695 config.listeners.forEach { it.afterTest() }696 }697 context.outputClassifications(11, config, random.seed)698 context.checkMaxSuccess(config, random.seed)699 return context700}701suspend fun <A, B, C, D, E, F, G, H, I, J, K, L> proptest(702 genA: Gen<A>,703 genB: Gen<B>,704 genC: Gen<C>,705 genD: Gen<D>,706 genE: Gen<E>,707 genF: Gen<F>,708 genG: Gen<G>,709 genH: Gen<H>,710 genI: Gen<I>,711 genJ: Gen<J>,712 genK: Gen<K>,713 genL: Gen<L>,714 config: PropTestConfig,715 property: suspend PropertyContext.(A, B, C, D, E, F, G, H, I, J, K, L) -> Unit716): PropertyContext {717 config.checkFailOnSeed()718 val constraints = config.constraints719 ?: config.iterations?.let { Constraints.iterations(it) }720 ?: Constraints.iterations(PropertyTesting.defaultIterationCount)721 val context = PropertyContext()722 val random = createRandom(config)723 genA.generate(random, config.edgeConfig)724 .zip(genB.generate(random, config.edgeConfig))725 .zip(genC.generate(random, config.edgeConfig))726 .zip(genD.generate(random, config.edgeConfig))727 .zip(genE.generate(random, config.edgeConfig))728 .zip(genF.generate(random, config.edgeConfig))729 .zip(genG.generate(random, config.edgeConfig))730 .zip(genH.generate(random, config.edgeConfig))731 .zip(genI.generate(random, config.edgeConfig))732 .zip(genJ.generate(random, config.edgeConfig))733 .zip(genK.generate(random, config.edgeConfig))734 .zip(genL.generate(random, config.edgeConfig))...

Full Screen

Full Screen

PropTestConfigConstraintsTest.kt

Source:PropTestConfigConstraintsTest.kt Github

copy

Full Screen

...14import kotlin.time.TimeSource15class PropTestConfigConstraintsTest : FunSpec() {16 init {17 test("PropTestConfig constraints should be used by proptest1 if present") {18 checkAll(Arb.int(1..1000)) { iterations ->19 var iterationCount = 020 proptest(21 Arb.int(),22 PropTestConfig(constraints = Constraints.iterations(iterations))23 ) {24 iterationCount++25 }26 iterationCount shouldBe iterations27 }28 }29 test("PropTestConfig constraints should be used by proptest2 if present") {30 checkAll(Arb.int(1..1000)) { iterations ->31 var iterationCount = 032 proptest(33 Arb.int(),34 Arb.int(),35 PropTestConfig(constraints = Constraints.iterations(iterations))36 ) { _, _ ->37 iterationCount++38 }39 iterationCount shouldBe iterations40 }41 }42 test("PropTestConfig constraints should be used by proptest3 if present") {43 checkAll(Arb.int(1..1000)) { iterations ->44 var iterationCount = 045 proptest(46 Arb.int(),47 Arb.int(),48 Arb.int(),49 PropTestConfig(constraints = Constraints.iterations(iterations))50 )51 { _, _, _ ->52 iterationCount++53 }54 iterationCount shouldBe iterations55 }56 }57 test("PropTestConfig constraints should be used by proptest4 if present") {58 checkAll(Arb.int(1..1000)) { iterations ->59 var iterationCount = 060 proptest(61 Arb.int(),62 Arb.int(),63 Arb.int(),64 Arb.int(),65 PropTestConfig(constraints = Constraints.iterations(iterations))66 )67 { _, _, _, _ ->68 iterationCount++69 }70 iterationCount shouldBe iterations71 }72 }73 test("PropTestConfig constraints should be used by proptest5 if present") {74 checkAll(Arb.int(1..1000)) { iterations ->75 var iterationCount = 076 proptest(77 Arb.int(),78 Arb.int(),79 Arb.int(),80 Arb.int(),81 Arb.int(),82 PropTestConfig(constraints = Constraints.iterations(iterations))83 )84 { _, _, _, _, _ ->85 iterationCount++86 }87 iterationCount shouldBe iterations88 }89 }90 test("PropTestConfig constraints should be used by proptest6 if present") {91 checkAll(Arb.int(1..1000)) { iterations ->92 var iterationCount = 093 proptest(94 Arb.int(),95 Arb.int(),96 Arb.int(),97 Arb.int(),98 Arb.int(),99 Arb.int(),100 PropTestConfig(constraints = Constraints.iterations(iterations))101 )102 { _, _, _, _, _, _ ->103 iterationCount++104 }105 iterationCount shouldBe iterations106 }107 }108 test("PropTestConfig constraints should be used by proptest7 if present") {109 checkAll(Arb.int(1..1000)) { iterations ->110 var iterationCount = 0111 proptest(112 Arb.int(),113 Arb.int(),114 Arb.int(),115 Arb.int(),116 Arb.int(),117 Arb.int(),118 Arb.int(),119 PropTestConfig(constraints = Constraints.iterations(iterations))120 )121 { _, _, _, _, _, _, _ ->122 iterationCount++123 }124 iterationCount shouldBe iterations125 }126 }127 test("PropTestConfig constraints should be used by proptest8 if present") {128 checkAll(Arb.int(1..1000)) { iterations ->129 var iterationCount = 0130 proptest(131 Arb.int(),132 Arb.int(),133 Arb.int(),134 Arb.int(),135 Arb.int(),136 Arb.int(),137 Arb.int(),138 Arb.int(),139 PropTestConfig(constraints = Constraints.iterations(iterations))140 )141 { _, _, _, _, _, _, _, _ ->142 iterationCount++143 }144 iterationCount shouldBe iterations145 }146 }147 test("PropTestConfig constraints should be used by proptest9 if present") {148 checkAll(Arb.int(1..1000)) { iterations ->149 var iterationCount = 0150 proptest(151 Arb.int(),152 Arb.int(),153 Arb.int(),154 Arb.int(),155 Arb.int(),156 Arb.int(),157 Arb.int(),158 Arb.int(),159 Arb.int(),160 PropTestConfig(constraints = Constraints.iterations(iterations))161 )162 { _, _, _, _, _, _, _, _, _ ->163 iterationCount++164 }165 iterationCount shouldBe iterations166 }167 }168 test("PropTestConfig constraints should be used by proptest10 if present") {169 checkAll(Arb.int(1..1000)) { iterations ->170 var iterationCount = 0171 proptest(172 Arb.int(),173 Arb.int(),174 Arb.int(),175 Arb.int(),176 Arb.int(),177 Arb.int(),178 Arb.int(),179 Arb.int(),180 Arb.int(),181 Arb.int(),182 PropTestConfig(constraints = Constraints.iterations(iterations))183 )184 { _, _, _, _, _, _, _, _, _, _ ->185 iterationCount++186 }187 iterationCount shouldBe iterations188 }189 }190 test("PropTestConfig constraints should be used by proptest11 if present") {191 checkAll(Arb.int(1..1000)) { iterations ->192 var iterationCount = 0193 proptest(194 Arb.int(),195 Arb.int(),196 Arb.int(),197 Arb.int(),198 Arb.int(),199 Arb.int(),200 Arb.int(),201 Arb.int(),202 Arb.int(),203 Arb.int(),204 Arb.int(),205 PropTestConfig(constraints = Constraints.iterations(iterations))206 )207 { _, _, _, _, _, _, _, _, _, _, _ ->208 iterationCount++209 }210 iterationCount shouldBe iterations211 }212 }213 test("PropTestConfig constraints should be used by proptest12 if present") {214 checkAll(Arb.int(1..1000)) { iterations ->215 var iterationCount = 0216 proptest(217 Arb.int(),218 Arb.int(),219 Arb.int(),220 Arb.int(),221 Arb.int(),222 Arb.int(),223 Arb.int(),224 Arb.int(),225 Arb.int(),226 Arb.int(),227 Arb.int(),228 Arb.int(),229 PropTestConfig(constraints = Constraints.iterations(iterations))230 )231 { _, _, _, _, _, _, _, _, _, _, _, _ ->232 iterationCount++233 }234 iterationCount shouldBe iterations235 }236 }237 test("PropTestConfig constraints should support durations") {238 val config = PropTestConfig(constraints = Constraints.duration(200.milliseconds))239 val start = TimeSource.Monotonic.markNow()240 checkAll(config, Arb.string()) { _ -> }241 // we should have exited around 200 millis242 start.elapsedNow().inWholeMilliseconds.shouldBeGreaterThan(150)243 start.elapsedNow().inWholeMilliseconds.shouldBeLessThan(300)244 }245 }246}...

Full Screen

Full Screen

propertyTest5.kt

Source:propertyTest5.kt Github

copy

Full Screen

...36 config,37 property38)39suspend fun <A, B, C, D, E> checkAll(40 iterations: Int,41 genA: Gen<A>,42 genB: Gen<B>,43 genC: Gen<C>,44 genD: Gen<D>,45 genE: Gen<E>,46 property: suspend PropertyContext.(A, B, C, D, E) -> Unit47): PropertyContext = proptest(genA, genB, genC, genD, genE, PropTestConfig(constraints = Constraints.iterations(iterations)), property)48suspend fun <A, B, C, D, E> checkAll(49 iterations: Int,50 config: PropTestConfig,51 genA: Gen<A>,52 genB: Gen<B>,53 genC: Gen<C>,54 genD: Gen<D>,55 genE: Gen<E>,56 property: suspend PropertyContext.(A, B, C, D, E) -> Unit57): PropertyContext = proptest(genA, genB, genC, genD, genE, config.copy(iterations = iterations), property)58suspend inline fun <reified A, reified B, reified C, reified D, reified E> checkAll(59 noinline property: suspend PropertyContext.(A, B, C, D, E) -> Unit60) = proptest(61 Arb.default(),62 Arb.default(),63 Arb.default(),64 Arb.default(),65 Arb.default(),66 PropTestConfig(),67 property68)69suspend inline fun <reified A, reified B, reified C, reified D, reified E> checkAll(70 config: PropTestConfig,71 noinline property: suspend PropertyContext.(A, B, C, D, E) -> Unit72) = proptest(73 Arb.default(),74 Arb.default(),75 Arb.default(),76 Arb.default(),77 Arb.default(),78 config,79 property80)81suspend inline fun <reified A, reified B, reified C, reified D, reified E> checkAll(82 iterations: Int,83 noinline property: suspend PropertyContext.(A, B, C, D, E) -> Unit84) = proptest(85 Arb.default(),86 Arb.default(),87 Arb.default(),88 Arb.default(),89 Arb.default(),90 PropTestConfig(constraints = Constraints.iterations(iterations)),91 property92)93suspend inline fun <reified A, reified B, reified C, reified D, reified E> checkAll(94 iterations: Int,95 config: PropTestConfig,96 noinline property: suspend PropertyContext.(A, B, C, D, E) -> Unit97) = proptest<A, B, C, D, E>(98 Arb.default<A>(),99 Arb.default<B>(),100 Arb.default<C>(),101 Arb.default<D>(),102 Arb.default<E>(),103 config.copy(iterations = iterations),104 property105)106suspend fun <A, B, C, D, E> forAll(107 genA: Gen<A>,108 genB: Gen<B>,109 genC: Gen<C>,110 genD: Gen<D>,111 genE: Gen<E>,112 property: suspend PropertyContext.(A, B, C, D, E) -> Boolean113) = forAll<A, B, C, D, E>(114 PropTestConfig(),115 genA,116 genB,117 genC,118 genD,119 genE,120 property121)122suspend fun <A, B, C, D, E> forAll(123 config: PropTestConfig = PropTestConfig(),124 genA: Gen<A>,125 genB: Gen<B>,126 genC: Gen<C>,127 genD: Gen<D>,128 genE: Gen<E>,129 property: suspend PropertyContext.(A, B, C, D, E) -> Boolean130) = proptest<A, B, C, D, E>(genA, genB, genC, genD, genE, config) { a, b, c, d, e ->131 property(132 a,133 b,134 c,135 d,136 e137 ) shouldBe true138}139suspend fun <A, B, C, D, E> forAll(140 iterations: Int,141 genA: Gen<A>,142 genB: Gen<B>,143 genC: Gen<C>,144 genD: Gen<D>,145 genE: Gen<E>,146 property: suspend PropertyContext.(A, B, C, D, E) -> Boolean147) = forAll<A, B, C, D, E>(PropTestConfig(constraints = Constraints.iterations(iterations)), genA, genB, genC, genD, genE, property)148suspend fun <A, B, C, D, E> forAll(149 iterations: Int,150 config: PropTestConfig,151 genA: Gen<A>,152 genB: Gen<B>,153 genC: Gen<C>,154 genD: Gen<D>,155 genE: Gen<E>,156 property: suspend PropertyContext.(A, B, C, D, E) -> Boolean157) = forAll<A, B, C, D, E>(config.copy(iterations = iterations), genA, genB, genC, genD, genE, property)158suspend inline fun <reified A, reified B, reified C, reified D, reified E> forAll(159 crossinline property: PropertyContext.(A, B, C, D, E) -> Boolean160): PropertyContext = forAll<A, B, C, D, E>(PropTestConfig(), property)161suspend inline fun <reified A, reified B, reified C, reified D, reified E> forAll(162 config: PropTestConfig = PropTestConfig(),163 crossinline property: PropertyContext.(A, B, C, D, E) -> Boolean164): PropertyContext = proptest(165 Arb.default<A>(),166 Arb.default<B>(),167 Arb.default<C>(),168 Arb.default<D>(),169 Arb.default<E>(),170 config171) { a, b, c, d, e -> property(a, b, c, d, e) shouldBe true }172suspend inline fun <reified A, reified B, reified C, reified D, reified E> forAll(173 iterations: Int,174 crossinline property: PropertyContext.(A, B, C, D, E) -> Boolean175) = forAll(PropTestConfig(constraints = Constraints.iterations(iterations)), property)176suspend inline fun <reified A, reified B, reified C, reified D, reified E> forAll(177 iterations: Int,178 config: PropTestConfig,179 crossinline property: PropertyContext.(A, B, C, D, E) -> Boolean180) = proptest(181 Arb.default<A>(),182 Arb.default<B>(),183 Arb.default<C>(),184 Arb.default<D>(),185 Arb.default<E>(),186 config.copy(iterations = iterations),187) { a, b, c, d, e -> property(a, b, c, d, e) shouldBe true }188suspend fun <A, B, C, D, E> forNone(189 config: PropTestConfig = PropTestConfig(),190 genA: Gen<A>,191 genB: Gen<B>,192 genC: Gen<C>,193 genD: Gen<D>,194 genE: Gen<E>,195 property: suspend PropertyContext.(A, B, C, D, E) -> Boolean196) = proptest<A, B, C, D, E>(genA, genB, genC, genD, genE, config) { a, b, c, d, e ->197 property(198 a,199 b,200 c,201 d,202 e203 ) shouldBe false204}205suspend fun <A, B, C, D, E> forNone(206 iterations: Int,207 genA: Gen<A>,208 genB: Gen<B>,209 genC: Gen<C>,210 genD: Gen<D>,211 genE: Gen<E>,212 property: suspend PropertyContext.(A, B, C, D, E) -> Boolean213): PropertyContext = forNone<A, B, C, D, E>(PropTestConfig(constraints = Constraints.iterations(iterations)), genA, genB, genC, genD, genE, property)214suspend fun <A, B, C, D, E> forNone(215 iterations: Int,216 config: PropTestConfig,217 genA: Gen<A>,218 genB: Gen<B>,219 genC: Gen<C>,220 genD: Gen<D>,221 genE: Gen<E>,222 property: suspend PropertyContext.(A, B, C, D, E) -> Boolean223) = forNone<A, B, C, D, E>(config.copy(iterations = iterations), genA, genB, genC, genD, genE, property)224suspend inline fun <reified A, reified B, reified C, reified D, reified E> forNone(225 crossinline property: PropertyContext.(A, B, C, D, E) -> Boolean226): PropertyContext = forNone<A, B, C, D, E>(PropTestConfig(), property)227suspend inline fun <reified A, reified B, reified C, reified D, reified E> forNone(228 config: PropTestConfig = PropTestConfig(),229 crossinline property: PropertyContext.(A, B, C, D, E) -> Boolean230): PropertyContext =231 proptest(232 Arb.default<A>(),233 Arb.default<B>(),234 Arb.default<C>(),235 Arb.default<D>(),236 Arb.default<E>(),237 config238 ) { a, b, c, d, e -> property(a, b, c, d, e) shouldBe false }239suspend inline fun <reified A, reified B, reified C, reified D, reified E> forNone(240 iterations: Int,241 crossinline property: PropertyContext.(A, B, C, D, E) -> Boolean242): PropertyContext = forNone(PropTestConfig(constraints = Constraints.iterations(iterations)), property)243suspend inline fun <reified A, reified B, reified C, reified D, reified E> forNone(244 iterations: Int,245 config: PropTestConfig,246 crossinline property: PropertyContext.(A, B, C, D, E) -> Boolean247) = forNone(config.copy(iterations = iterations), property)...

Full Screen

Full Screen

propertyTest4.kt

Source:propertyTest4.kt Github

copy

Full Screen

...26 property: suspend PropertyContext.(A, B, C, D) -> Unit27): PropertyContext =28 proptest(genA, genB, genC, genD, config, property)29suspend fun <A, B, C, D> checkAll(30 iterations: Int,31 genA: Gen<A>,32 genB: Gen<B>,33 genC: Gen<C>,34 genD: Gen<D>,35 property: suspend PropertyContext.(A, B, C, D) -> Unit36): PropertyContext = checkAll(PropTestConfig(constraints = Constraints.iterations(iterations)), genA, genB, genC, genD, property)37suspend fun <A, B, C, D> checkAll(38 iterations: Int,39 config: PropTestConfig,40 genA: Gen<A>,41 genB: Gen<B>,42 genC: Gen<C>,43 genD: Gen<D>,44 property: suspend PropertyContext.(A, B, C, D) -> Unit45): PropertyContext = checkAll(config.copy(iterations = iterations), genA, genB, genC, genD, property)46suspend inline fun <reified A, reified B, reified C, reified D> checkAll(47 noinline property: suspend PropertyContext.(A, B, C, D) -> Unit48) = proptest(49 Arb.default<A>(),50 Arb.default<B>(),51 Arb.default<C>(),52 Arb.default<D>(),53 PropTestConfig(),54 property55)56suspend inline fun <reified A, reified B, reified C, reified D> checkAll(57 config: PropTestConfig,58 noinline property: suspend PropertyContext.(A, B, C, D) -> Unit59) = proptest<A, B, C, D>(60 Arb.default<A>(),61 Arb.default<B>(),62 Arb.default<C>(),63 Arb.default<D>(),64 config,65 property66)67suspend inline fun <reified A, reified B, reified C, reified D> checkAll(68 iterations: Int,69 noinline property: suspend PropertyContext.(A, B, C, D) -> Unit70) = proptest(71 Arb.default<A>(),72 Arb.default<B>(),73 Arb.default<C>(),74 Arb.default<D>(),75 PropTestConfig(constraints = Constraints.iterations(iterations)),76 property77)78suspend inline fun <reified A, reified B, reified C, reified D> checkAll(79 iterations: Int,80 config: PropTestConfig,81 noinline property: suspend PropertyContext.(A, B, C, D) -> Unit82) = proptest(83 Arb.default<A>(),84 Arb.default<B>(),85 Arb.default<C>(),86 Arb.default<D>(),87 config.copy(iterations = iterations),88 property89)90suspend fun <A, B, C, D> forAll(91 genA: Gen<A>,92 genB: Gen<B>,93 genC: Gen<C>,94 genD: Gen<D>,95 property: suspend PropertyContext.(A, B, C, D) -> Boolean96) = forAll<A, B, C, D>(97 PropTestConfig(),98 genA,99 genB,100 genC,101 genD,102 property103)104suspend fun <A, B, C, D> forAll(105 config: PropTestConfig = PropTestConfig(),106 genA: Gen<A>,107 genB: Gen<B>,108 genC: Gen<C>,109 genD: Gen<D>,110 property: suspend PropertyContext.(A, B, C, D) -> Boolean111) = proptest<A, B, C, D>(genA, genB, genC, genD, config) { a, b, c, d -> property(a, b, c, d) shouldBe true }112suspend fun <A, B, C, D> forAll(113 iterations: Int,114 genA: Gen<A>,115 genB: Gen<B>,116 genC: Gen<C>,117 genD: Gen<D>,118 property: suspend PropertyContext.(A, B, C, D) -> Boolean119) = forAll<A, B, C, D>(iterations, PropTestConfig(), genA, genB, genC, genD, property)120suspend fun <A, B, C, D> forAll(121 iterations: Int,122 config: PropTestConfig,123 genA: Gen<A>,124 genB: Gen<B>,125 genC: Gen<C>,126 genD: Gen<D>,127 property: suspend PropertyContext.(A, B, C, D) -> Boolean128) = forAll(config.copy(iterations = iterations), genA, genB, genC, genD, property)129suspend inline fun <reified A, reified B, reified C, reified D> forAll(130 crossinline property: PropertyContext.(A, B, C, D) -> Boolean131): PropertyContext = forAll(PropTestConfig(), property)132suspend inline fun <reified A, reified B, reified C, reified D> forAll(133 config: PropTestConfig = PropTestConfig(),134 crossinline property: PropertyContext.(A, B, C, D) -> Boolean135): PropertyContext = proptest(136 Arb.default<A>(),137 Arb.default<B>(),138 Arb.default<C>(),139 Arb.default<D>(),140 config141) { a, b, c, d -> property(a, b, c, d) shouldBe true }142suspend inline fun <reified A, reified B, reified C, reified D> forAll(143 iterations: Int,144 crossinline property: PropertyContext.(A, B, C, D) -> Boolean145) = forAll(iterations, PropTestConfig(), property)146suspend inline fun <reified A, reified B, reified C, reified D> forAll(147 iterations: Int,148 config: PropTestConfig,149 crossinline property: PropertyContext.(A, B, C, D) -> Boolean150) = forAll(config.copy(iterations = iterations), property)151suspend fun <A, B, C, D> forNone(152 genA: Gen<A>,153 genB: Gen<B>,154 genC: Gen<C>,155 genD: Gen<D>,156 property: suspend PropertyContext.(A, B, C, D) -> Boolean157) = forNone<A, B, C, D>(158 PropTestConfig(),159 genA,160 genB,161 genC,162 genD,163 property164)165suspend fun <A, B, C, D> forNone(166 config: PropTestConfig = PropTestConfig(),167 genA: Gen<A>,168 genB: Gen<B>,169 genC: Gen<C>,170 genD: Gen<D>,171 property: suspend PropertyContext.(A, B, C, D) -> Boolean172) = proptest<A, B, C, D>(genA, genB, genC, genD, config) { a, b, c, d -> property(a, b, c, d) shouldBe false }173suspend fun <A, B, C, D> forNone(174 iterations: Int,175 genA: Gen<A>,176 genB: Gen<B>,177 genC: Gen<C>,178 genD: Gen<D>,179 property: suspend PropertyContext.(A, B, C, D) -> Boolean180) = forNone<A, B, C, D>(iterations, PropTestConfig(), genA, genB, genC, genD, property)181suspend fun <A, B, C, D> forNone(182 iterations: Int,183 config: PropTestConfig,184 genA: Gen<A>,185 genB: Gen<B>,186 genC: Gen<C>,187 genD: Gen<D>,188 property: suspend PropertyContext.(A, B, C, D) -> Boolean189) = forNone<A, B, C, D>(config.copy(iterations = iterations), genA, genB, genC, genD, property)190suspend inline fun <reified A, reified B, reified C, reified D> forNone(191 crossinline property: PropertyContext.(A, B, C, D) -> Boolean192): PropertyContext = forNone(PropTestConfig(), property)193suspend inline fun <reified A, reified B, reified C, reified D> forNone(194 config: PropTestConfig = PropTestConfig(),195 crossinline property: PropertyContext.(A, B, C, D) -> Boolean196): PropertyContext = proptest(197 Arb.default<A>(),198 Arb.default<B>(),199 Arb.default<C>(),200 Arb.default<D>(),201 config202) { a, b, c, d -> property(a, b, c, d) shouldBe false }203suspend inline fun <reified A, reified B, reified C, reified D> forNone(204 iterations: Int,205 crossinline property: PropertyContext.(A, B, C, D) -> Boolean206) = forNone(iterations, PropTestConfig(), property)207suspend inline fun <reified A, reified B, reified C, reified D> forNone(208 iterations: Int,209 config: PropTestConfig,210 crossinline property: PropertyContext.(A, B, C, D) -> Boolean211) = forNone(config.copy(iterations = iterations), property)...

Full Screen

Full Screen

propertyTest1.kt

Source:propertyTest1.kt Github

copy

Full Screen

...10 genA: Gen<A>,11 property: suspend PropertyContext.(A) -> Unit12): PropertyContext = proptest(genA, PropTestConfig(), property)13@JvmName("checkAllExt")14suspend fun <A> Gen<A>.checkAll(iterations: Int, property: suspend PropertyContext.(A) -> Unit) =15 checkAll(iterations, this, property)16suspend fun <A> checkAll(17 iterations: Int,18 genA: Gen<A>,19 property: suspend PropertyContext.(A) -> Unit20): PropertyContext = proptest(genA, PropTestConfig(constraints = Constraints.iterations(iterations)), property)21@JvmName("checkAllExt")22suspend fun <A> Gen<A>.checkAll(config: PropTestConfig, property: suspend PropertyContext.(A) -> Unit) =23 checkAll(config, this, property)24suspend fun <A> checkAll(25 config: PropTestConfig,26 genA: Gen<A>,27 property: suspend PropertyContext.(A) -> Unit28): PropertyContext = proptest(genA, config, property)29@JvmName("checkAllExt")30suspend fun <A> Gen<A>.checkAll(31 iterations: Int,32 config: PropTestConfig,33 property: suspend PropertyContext.(A) -> Unit34) = checkAll(iterations, config, this, property)35suspend fun <A> checkAll(36 iterations: Int,37 config: PropTestConfig,38 genA: Gen<A>,39 property: suspend PropertyContext.(A) -> Unit40): PropertyContext = proptest(genA, config.copy(iterations = iterations), property)41suspend inline fun <reified A> checkAll(42 noinline property: suspend PropertyContext.(A) -> Unit43): PropertyContext = proptest(44 Arb.default<A>(),45 PropTestConfig(),46 property47)48suspend inline fun <reified A> checkAll(49 iterations: Int,50 noinline property: suspend PropertyContext.(A) -> Unit51): PropertyContext = proptest(52 Arb.default<A>(),53 PropTestConfig(constraints = Constraints.iterations(iterations)),54 property55)56suspend inline fun <reified A> checkAll(57 config: PropTestConfig,58 noinline property: suspend PropertyContext.(A) -> Unit59): PropertyContext = proptest(60 Arb.default<A>(),61 config,62 property63)64suspend inline fun <reified A> checkAll(65 iterations: Int,66 config: PropTestConfig,67 noinline property: suspend PropertyContext.(A) -> Unit68): PropertyContext = proptest(69 Arb.default<A>(),70 config.copy(iterations = iterations),71 property72)73@JvmName("forAllExt")74suspend fun <A> Gen<A>.forAll(property: suspend PropertyContext.(A) -> Boolean) =75 forAll(this, property)76suspend fun <A> forAll(77 genA: Gen<A>,78 property: suspend PropertyContext.(A) -> Boolean79) = forAll(PropTestConfig(), genA, property)80@JvmName("forAllExt")81suspend fun <A> Gen<A>.forAll(iterations: Int, property: suspend PropertyContext.(A) -> Boolean) =82 forAll(iterations, this, property)83suspend fun <A> forAll(84 iterations: Int,85 genA: Gen<A>,86 property: suspend PropertyContext.(A) -> Boolean87) = forAll(iterations, PropTestConfig(), genA, property)88@JvmName("forAllExt")89suspend fun <A> Gen<A>.forAll(config: PropTestConfig, property: suspend PropertyContext.(A) -> Boolean) =90 forAll(config, this, property)91suspend fun <A> forAll(92 config: PropTestConfig,93 genA: Gen<A>,94 property: suspend PropertyContext.(A) -> Boolean95) = proptest(genA, config) { a -> property(a) shouldBe true }96@JvmName("forAllExt")97suspend fun <A> Gen<A>.forAll(iterations: Int, config: PropTestConfig, property: suspend PropertyContext.(A) -> Boolean) =98 forAll(config.copy(iterations = iterations), this, property)99suspend fun <A> forAll(100 iterations: Int,101 config: PropTestConfig,102 genA: Gen<A>,103 property: suspend PropertyContext.(A) -> Boolean104) = forAll(config.copy(iterations = iterations), genA, property)105suspend inline fun <reified A> forAll(106 crossinline property: PropertyContext.(A) -> Boolean107) = forAll(PropTestConfig(), property)108suspend inline fun <reified A> forAll(109 iterations: Int,110 crossinline property: PropertyContext.(A) -> Boolean111): PropertyContext = forAll(PropTestConfig(constraints = Constraints.iterations(iterations)), property)112suspend inline fun <reified A> forAll(113 config: PropTestConfig,114 crossinline property: PropertyContext.(A) -> Boolean115) = proptest<A>(116 Arb.default<A>(),117 config118) { a -> property(a) shouldBe true }119suspend inline fun <reified A> forAll(120 iterations: Int,121 config: PropTestConfig,122 crossinline property: PropertyContext.(A) -> Boolean123) = proptest<A>(124 Arb.default<A>(),125 config.copy(iterations = iterations)126) { a -> property(a) shouldBe true }127@JvmName("forNoneExt")128suspend fun <A> Gen<A>.forNone(property: suspend PropertyContext.(A) -> Boolean) =129 forNone(this, property)130suspend fun <A> forNone(131 genA: Gen<A>,132 property: suspend PropertyContext.(A) -> Boolean133) = forNone(PropTestConfig(), genA, property)134@JvmName("forNoneExt")135suspend fun <A> Gen<A>.forNone(iterations: Int, property: suspend PropertyContext.(A) -> Boolean) =136 forAll(iterations, this, property)137suspend fun <A> forNone(138 iterations: Int,139 genA: Gen<A>,140 property: suspend PropertyContext.(A) -> Boolean141) = forNone(iterations, PropTestConfig(), genA, property)142@JvmName("forNoneExt")143suspend fun <A> Gen<A>.forNone(config: PropTestConfig, property: suspend PropertyContext.(A) -> Boolean) =144 forNone(config, this, property)145suspend fun <A> forNone(146 config: PropTestConfig,147 genA: Gen<A>,148 property: suspend PropertyContext.(A) -> Boolean149) = proptest<A>(150 genA,151 config152) { a -> property(a) shouldBe false }153@JvmName("forNoneExt")154suspend fun <A> Gen<A>.forNone(155 iterations: Int,156 config: PropTestConfig,157 property: suspend PropertyContext.(A) -> Boolean158) =159 forNone(iterations, config, this, property)160suspend fun <A> forNone(161 iterations: Int,162 config: PropTestConfig,163 genA: Gen<A>,164 property: suspend PropertyContext.(A) -> Boolean165) = forNone(config.copy(iterations = iterations), genA, property)166suspend inline fun <reified A> forNone(167 crossinline property: PropertyContext.(A) -> Boolean168) = forNone(PropTestConfig(), property)169suspend inline fun <reified A> forNone(170 iterations: Int,171 crossinline property: PropertyContext.(A) -> Boolean172) = forNone(iterations, PropTestConfig(), property)173suspend inline fun <reified A> forNone(174 config: PropTestConfig,175 crossinline property: PropertyContext.(A) -> Boolean176) = proptest<A>(177 Arb.default<A>(),178 config179) { a -> property(a) shouldBe false }180suspend inline fun <reified A> forNone(181 iterations: Int,182 config: PropTestConfig,183 crossinline property: PropertyContext.(A) -> Boolean184) = forNone(config.copy(iterations = iterations), property)...

Full Screen

Full Screen

propertyTest3.kt

Source:propertyTest3.kt Github

copy

Full Screen

...23 property: suspend PropertyContext.(A, B, C) -> Unit24): PropertyContext =25 proptest(genA, genB, genC, config, property)26suspend fun <A, B, C> checkAll(27 iterations: Int,28 genA: Gen<A>,29 genB: Gen<B>,30 genC: Gen<C>,31 property: suspend PropertyContext.(A, B, C) -> Unit32): PropertyContext = proptest(genA, genB, genC, PropTestConfig(constraints = Constraints.iterations(iterations)), property)33suspend fun <A, B, C> checkAll(34 iterations: Int,35 config: PropTestConfig,36 genA: Gen<A>,37 genB: Gen<B>,38 genC: Gen<C>,39 property: suspend PropertyContext.(A, B, C) -> Unit40): PropertyContext = proptest(genA, genB, genC, config.copy(iterations = iterations), property)41suspend inline fun <reified A, reified B, reified C> checkAll(42 noinline property: suspend PropertyContext.(A, B, C) -> Unit43) = proptest(44 Arb.default(),45 Arb.default(),46 Arb.default(),47 PropTestConfig(),48 property49)50suspend inline fun <reified A, reified B, reified C> checkAll(51 config: PropTestConfig,52 noinline property: suspend PropertyContext.(A, B, C) -> Unit53) = proptest(54 Arb.default(),55 Arb.default(),56 Arb.default(),57 config,58 property59)60suspend inline fun <reified A, reified B, reified C> checkAll(61 iterations: Int,62 noinline property: suspend PropertyContext.(A, B, C) -> Unit63) = proptest(64 Arb.default(),65 Arb.default(),66 Arb.default(),67 PropTestConfig(constraints = Constraints.iterations(iterations)),68 property69)70suspend inline fun <reified A, reified B, reified C> checkAll(71 iterations: Int,72 config: PropTestConfig,73 noinline property: suspend PropertyContext.(A, B, C) -> Unit74) = proptest(75 Arb.default(),76 Arb.default(),77 Arb.default(),78 config.copy(iterations = iterations),79 property80)81suspend fun <A, B, C> forAll(82 genA: Gen<A>,83 genB: Gen<B>,84 genC: Gen<C>,85 property: suspend PropertyContext.(A, B, C) -> Boolean86) = forAll(87 PropTestConfig(),88 genA,89 genB,90 genC,91 property92)93suspend fun <A, B, C> forAll(94 config: PropTestConfig = PropTestConfig(),95 genA: Gen<A>,96 genB: Gen<B>,97 genC: Gen<C>,98 property: suspend PropertyContext.(A, B, C) -> Boolean99) = proptest(genA, genB, genC, config) { a, b, c -> property(a, b, c) shouldBe true }100suspend fun <A, B, C> forAll(101 iterations: Int,102 genA: Gen<A>,103 genB: Gen<B>,104 genC: Gen<C>,105 property: suspend PropertyContext.(A, B, C) -> Boolean106) = forAll(iterations, PropTestConfig(), genA, genB, genC, property)107suspend fun <A, B, C> forAll(108 iterations: Int,109 config: PropTestConfig,110 genA: Gen<A>,111 genB: Gen<B>,112 genC: Gen<C>,113 property: suspend PropertyContext.(A, B, C) -> Boolean114) = forAll(config.copy(iterations = iterations), genA, genB, genC, property)115suspend inline fun <reified A, reified B, reified C> forAll(116 crossinline property: PropertyContext.(A, B, C) -> Boolean117): PropertyContext = forAll(PropTestConfig(), property)118suspend inline fun <reified A, reified B, reified C> forAll(119 config: PropTestConfig = PropTestConfig(),120 crossinline property: PropertyContext.(A, B, C) -> Boolean121): PropertyContext = proptest<A, B, C>(122 Arb.default(),123 Arb.default(),124 Arb.default(),125 config126) { a, b, c -> property(a, b, c) shouldBe true }127suspend inline fun <reified A, reified B, reified C> forAll(128 iterations: Int,129 crossinline property: PropertyContext.(A, B, C) -> Boolean130) = forAll(iterations, PropTestConfig(), property)131suspend inline fun <reified A, reified B, reified C> forAll(132 iterations: Int,133 config: PropTestConfig,134 crossinline property: PropertyContext.(A, B, C) -> Boolean135) = forAll(config.copy(iterations = iterations), property)136suspend fun <A, B, C> forNone(137 genA: Gen<A>,138 genB: Gen<B>,139 genC: Gen<C>,140 property: suspend PropertyContext.(A, B, C) -> Boolean141) = forNone(142 PropTestConfig(),143 genA,144 genB,145 genC,146 property147)148suspend fun <A, B, C> forNone(149 config: PropTestConfig = PropTestConfig(),150 genA: Gen<A>,151 genB: Gen<B>,152 genC: Gen<C>,153 property: suspend PropertyContext.(A, B, C) -> Boolean154) = proptest(genA, genB, genC, config) { a, b, c -> property(a, b, c) shouldBe false }155suspend fun <A, B, C> forNone(156 iterations: Int,157 genA: Gen<A>,158 genB: Gen<B>,159 genC: Gen<C>,160 property: suspend PropertyContext.(A, B, C) -> Boolean161) = forNone(iterations, PropTestConfig(), genA, genB, genC, property)162suspend fun <A, B, C> forNone(163 iterations: Int,164 config: PropTestConfig,165 genA: Gen<A>,166 genB: Gen<B>,167 genC: Gen<C>,168 property: suspend PropertyContext.(A, B, C) -> Boolean169) = forNone(config.copy(iterations = iterations), genA, genB, genC, property)170suspend inline fun <reified A, reified B, reified C> forNone(171 crossinline property: PropertyContext.(A, B, C) -> Boolean172): PropertyContext = forNone(PropTestConfig(), property)173suspend inline fun <reified A, reified B, reified C> forNone(174 config: PropTestConfig = PropTestConfig(),175 crossinline property: PropertyContext.(A, B, C) -> Boolean176): PropertyContext = proptest(177 Arb.default<A>(),178 Arb.default<B>(),179 Arb.default<C>(),180 config181) { a, b, c -> property(a, b, c) shouldBe false }182suspend inline fun <reified A, reified B, reified C> forNone(183 iterations: Int,184 crossinline property: PropertyContext.(A, B, C) -> Boolean185) = forNone(iterations, PropTestConfig(), property)186suspend inline fun <reified A, reified B, reified C> forNone(187 iterations: Int,188 config: PropTestConfig,189 crossinline property: PropertyContext.(A, B, C) -> Boolean190) = forNone(config.copy(iterations = iterations), property)...

Full Screen

Full Screen

propertyTest2.kt

Source:propertyTest2.kt Github

copy

Full Screen

...14 genB: Gen<B>,15 property: suspend PropertyContext.(A, B) -> Unit16): PropertyContext = proptest(genA, genB, config, property)17suspend fun <A, B> checkAll(18 iterations: Int,19 genA: Gen<A>,20 genB: Gen<B>,21 property: suspend PropertyContext.(A, B) -> Unit22): PropertyContext = proptest(genA, genB, PropTestConfig(constraints = Constraints.iterations(iterations)), property)23suspend fun <A, B> checkAll(24 iterations: Int,25 config: PropTestConfig,26 genA: Gen<A>,27 genB: Gen<B>,28 property: suspend PropertyContext.(A, B) -> Unit29): PropertyContext = proptest(genA, genB, config.copy(iterations = iterations), property)30suspend inline fun <reified A, reified B> checkAll(31 noinline property: suspend PropertyContext.(A, B) -> Unit32) = proptest(33 Arb.default(),34 Arb.default(),35 PropTestConfig(),36 property37)38suspend inline fun <reified A, reified B> PropTest.checkAll(39 noinline property: suspend PropertyContext.(A, B) -> Unit40) = proptest(41 Arb.default(),42 Arb.default(),43 this.toPropTestConfig(),44 property45)46suspend inline fun <reified A, reified B> checkAll(47 config: PropTestConfig,48 noinline property: suspend PropertyContext.(A, B) -> Unit49) = proptest(50 Arb.default(),51 Arb.default(),52 config,53 property54)55suspend inline fun <reified A, reified B> checkAll(56 iterations: Int,57 noinline property: suspend PropertyContext.(A, B) -> Unit58) = proptest(59 Arb.default(),60 Arb.default(),61 PropTestConfig(constraints = Constraints.iterations(iterations)),62 property63)64suspend inline fun <reified A, reified B> checkAll(65 iterations: Int,66 config: PropTestConfig,67 noinline property: suspend PropertyContext.(A, B) -> Unit68) = proptest(69 Arb.default(),70 Arb.default(),71 config.copy(iterations = iterations),72 property73)74suspend fun <A, B> forAll(75 genA: Gen<A>,76 genB: Gen<B>,77 property: suspend PropertyContext.(A, B) -> Boolean78) = forAll(PropTestConfig(), genA, genB, property)79suspend fun <A, B> forAll(80 config: PropTestConfig = PropTestConfig(),81 genA: Gen<A>,82 genB: Gen<B>,83 property: suspend PropertyContext.(A, B) -> Boolean84) = proptest(genA, genB, config) { a, b -> property(a, b) shouldBe true }85suspend fun <A, B> forAll(86 iterations: Int,87 genA: Gen<A>,88 genB: Gen<B>,89 property: suspend PropertyContext.(A, B) -> Boolean90) = forAll(iterations, PropTestConfig(), genA, genB, property)91suspend fun <A, B> forAll(92 iterations: Int,93 config: PropTestConfig,94 genA: Gen<A>,95 genB: Gen<B>,96 property: suspend PropertyContext.(A, B) -> Boolean97) = forAll(config.copy(iterations = iterations), genA, genB, property)98suspend inline fun <reified A, reified B> forAll(99 crossinline property: PropertyContext.(A, B) -> Boolean100): PropertyContext = forAll(PropTestConfig(), property)101suspend inline fun <reified A, reified B> forAll(102 config: PropTestConfig = PropTestConfig(),103 crossinline property: PropertyContext.(A, B) -> Boolean104): PropertyContext = proptest<A, B>(105 Arb.default(),106 Arb.default(),107 config,108) { a, b -> property(a, b) shouldBe true }109suspend inline fun <reified A, reified B> forAll(110 iterations: Int,111 crossinline property: PropertyContext.(A, B) -> Boolean112) = forAll(iterations, PropTestConfig(), property)113suspend inline fun <reified A, reified B> forAll(114 iterations: Int,115 config: PropTestConfig,116 crossinline property: PropertyContext.(A, B) -> Boolean117) = forAll(config.copy(iterations = iterations), property)118suspend fun <A, B> forNone(119 genA: Gen<A>,120 genB: Gen<B>,121 property: suspend PropertyContext.(A, B) -> Boolean122) = forNone(PropTestConfig(), genA, genB, property)123suspend fun <A, B> forNone(124 config: PropTestConfig = PropTestConfig(),125 genA: Gen<A>,126 genB: Gen<B>,127 property: suspend PropertyContext.(A, B) -> Boolean128) = proptest(genA, genB, config) { a, b -> property(a, b) shouldBe false }129suspend fun <A, B> forNone(130 iterations: Int,131 genA: Gen<A>,132 genB: Gen<B>,133 property: suspend PropertyContext.(A, B) -> Boolean134) = forNone(iterations, PropTestConfig(), genA, genB, property)135suspend fun <A, B> forNone(136 iterations: Int,137 config: PropTestConfig,138 genA: Gen<A>,139 genB: Gen<B>,140 property: suspend PropertyContext.(A, B) -> Boolean141) = forNone(config.copy(iterations = iterations), genA, genB, property)142suspend inline fun <reified A, reified B> forNone(143 crossinline property: PropertyContext.(A, B) -> Boolean144): PropertyContext = forNone(PropTestConfig(), property)145suspend inline fun <reified A, reified B> forNone(146 config: PropTestConfig = PropTestConfig(),147 crossinline property: PropertyContext.(A, B) -> Boolean148): PropertyContext = proptest<A, B>(149 Arb.default(),150 Arb.default(),151 config152) { a, b -> property(a, b) shouldBe false }153suspend inline fun <reified A, reified B> forNone(154 iterations: Int,155 crossinline property: PropertyContext.(A, B) -> Boolean156) = forNone(iterations, PropTestConfig(), property)157suspend inline fun <reified A, reified B> forNone(158 iterations: Int,159 config: PropTestConfig,160 crossinline property: PropertyContext.(A, B) -> Boolean161) = forNone(config.copy(iterations = iterations), property)...

Full Screen

Full Screen

config.kt

Source:config.kt Github

copy

Full Screen

...58 val seed: Long? = PropertyTesting.defaultSeed,59 val minSuccess: Int = PropertyTesting.defaultMinSuccess,60 val maxFailure: Int = PropertyTesting.defaultMaxFailure,61 val shrinkingMode: ShrinkingMode = PropertyTesting.defaultShrinkingMode,62 val iterations: Int? = null,63 val listeners: List<PropTestListener> = PropertyTesting.defaultListeners,64 val edgeConfig: EdgeConfig = EdgeConfig.default(),65 val constraints: Constraints? = null,66)67fun PropTest.toPropTestConfig() =68 PropTestConfig(69 seed = seed,70 minSuccess = minSuccess,71 maxFailure = maxFailure,72 iterations = iterations,73 shrinkingMode = shrinkingMode,74 listeners = listeners,75 edgeConfig = edgeConfig76 )77/**78 * Property Test Configuration to be used by the underlying property test runner79 *80 * @param iterations The number of iterations to run. If null either the global [PropertyTesting]'s default value81 * will be used, or the minimum iterations required for the supplied generations. Whichever is82 * greater.83 *84 * @param constraints controls the loop for properties. See [Constraints].85 */86@OptIn(ExperimentalKotest::class)87data class PropTestConfig(88 val seed: Long? = PropertyTesting.defaultSeed,89 val minSuccess: Int = PropertyTesting.defaultMinSuccess,90 val maxFailure: Int = PropertyTesting.defaultMaxFailure,91 val shrinkingMode: ShrinkingMode = PropertyTesting.defaultShrinkingMode,92 val iterations: Int? = null,93 val listeners: List<PropTestListener> = PropertyTesting.defaultListeners,94 val edgeConfig: EdgeConfig = EdgeConfig.default(),95 val outputClassifications: Boolean = PropertyTesting.defaultOutputClassifications,96 val labelsReporter: LabelsReporter = StandardLabelsReporter,97 val constraints: Constraints? = null,98)99interface PropTestListener {100 suspend fun beforeTest(): Unit = Unit101 suspend fun afterTest(): Unit = Unit102}...

Full Screen

Full Screen

iterations

Using AI Code Generation

copy

Full Screen

1val constraints = Constraints ( min = 1, max = 10, start = 1, end = 10, step = 1, iterations = 100 )2val constraints = Constraints ( min = 1, max = 10 )3val constraints = Constraints ( start = 1, end = 10, step = 1 )4val constraints = Constraints ( random = Random )5val constraints = Constraints ( random = Random )6val constraints = Constraints ( random = Random )7val constraints = Constraints ( random = Random )8val constraints = Constraints ( random = Random )9val constraints = Constraints ( random = Random )

Full Screen

Full Screen

iterations

Using AI Code Generation

copy

Full Screen

1property("list should have size") {2 forAll<Int, List<Int>> { i, l ->3 }.config(invocations = 100)4}5property("list should have size") {6 forAll<Int, List<Int>> { i, l ->7 }.config(iterations = 100)8}9property("list should have size") {10 forAll<Int, List<Int>> { i, l ->11 }.config(minSuccessful = 100)12}13property("list should have size") {14 forAll<Int, List<Int>> { i, l ->15 }.config(minSize = 100)16}17property("list should have size") {18 forAll<Int, List<Int>> { i, l ->19 }.config(maxSize =

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Kotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful