How to use Exhaustive.merge method of io.kotest.property.exhaustive.Exhaustive class

Best Kotest code snippet using io.kotest.property.exhaustive.Exhaustive.Exhaustive.merge

JSONGenerators.kt

Source:JSONGenerators.kt Github

copy

Full Screen

1/*2 * Copyright (c) 2021 OneAndOlaf3 *4 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated5 * documentation files (the “Software”), to deal in the Software without restriction, including without limitation the6 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to7 * permit persons to whom the Software is furnished to do so, subject to the following conditions:8 *9 * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the10 * Software.11 *12 * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE13 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR14 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR15 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.16 */17package com.github.oneandolaf.jsonext.testutils18import com.github.oneandolaf.jsonext.extensions.jsonArrayOf19import com.github.oneandolaf.jsonext.extensions.jsonObjectOf20import io.kotest.property.Exhaustive21import io.kotest.property.exhaustive.exhaustive22import io.kotest.property.exhaustive.map23import io.kotest.property.exhaustive.plus24import org.json.JSONArray25import org.json.JSONObject26import java.math.BigDecimal27import java.math.BigInteger28object JSONGenerators {29 val bools = listOf(true, false).exhaustive()30 val explicitNull = listOf(JSONObject.NULL).exhaustive()31 val doubles = listOf(32 0.0,33 1.0,34 -1.0,35 5.0,36 Math.PI,37 42.415638 ).exhaustive()39 val doubleStrings = doubles.map { it.toString() }40 val floats = listOf(41 0.0f,42 1.0f,43 -1.0f,44 5.0f,45 42.41561f46 ).exhaustive()47 val bigDecimals = listOf(48 BigDecimal.ZERO,49 BigDecimal.ONE,50 BigDecimal.TEN,51 BigDecimal("-1.0"),52 BigDecimal("-42.5"),53 BigDecimal("0.5"),54 BigDecimal("42.4541")55 ).exhaustive()56 val ints = listOf(57 0,58 1,59 -1,60 5,61 4262 ).exhaustive()63 val intStrings = ints.map { it.toString() }64 val bigIntegers = listOf(65 BigInteger.ZERO,66 BigInteger.ONE,67 BigInteger.TEN,68 BigInteger.valueOf(-1L),69 BigInteger.valueOf(5L),70 BigInteger.valueOf(42L)71 ).exhaustive()72 val longs = listOf(73 0L,74 1L,75 -1L,76 5L,77 42L78 ).exhaustive()79 /**80 * Strings that are not representations of booleans or numbers.81 */82 val basicStrings = listOf(83 "",84 "a",85 "foo",86 "long long string"87 ).exhaustive()88 /**89 * Strings that are representations of booleans.90 */91 val booleanStrings = listOf(92 "true",93 "false",94 "True",95 "TRUE",96 "False",97 "FALSE"98 ).exhaustive()99 /**100 * Strings that are representations of numbers.101 */102 val numericStrings = intStrings + doubleStrings103 /**104 * All strings.105 */106 val allStrings = basicStrings + booleanStrings + numericStrings107 val arrays = mutableExhaustive {108 listOf(109 JSONArray(),110 jsonArrayOf(""),111 jsonArrayOf("foo"),112 jsonArrayOf(true),113 jsonArrayOf(false),114 jsonArrayOf(42),115 jsonArrayOf(5.0),116 jsonArrayOf(emptyList<Any>()),117 jsonArrayOf(jsonArrayOf("foo")),118 jsonArrayOf(jsonObjectOf()),119 jsonArrayOf("bar", 5, true, jsonArrayOf("hello", "world"), jsonObjectOf("foo" to false))120 ).exhaustive()121 }122 val arraysAsLists = arrays.mapMutable { it.toList() }123 val objects = mutableExhaustive {124 listOf(125 JSONObject(),126 jsonObjectOf("foo" to true),127 jsonObjectOf("a" to "a string", "b" to 2),128 jsonObjectOf("i am null" to JSONObject.NULL),129 jsonObjectOf(130 "str" to "foo",131 "int" to 42,132 "double" to 2.5,133 "bool" to false,134 "subObj" to mapOf("substr" to "hello"),135 "subArr" to listOf(1, "foo", true, emptyList<Any>())136 ),137 ).exhaustive()138 }139 val objectsAsMaps = objects.mapMutable { it.toMap() }140 val nonNullValues = mutableExhaustive {141 bools + doubles + ints + arrays + objects + longs + allStrings142 }143 val values = mutableExhaustive { nonNullValues + explicitNull }144 /**145 * Primitive numbers that can be JSON values (ints, longs, doubles, and floats).146 */147 val numbers: Exhaustive<Number> = ints + doubles + floats + longs148 /**149 * Combination of numbers and the string representations of ints.150 */151 val intLikes = numbers + intStrings152 /**153 * Combination of numbers that can be JSON values, and String representations of numbers.154 */155 val numberLikes = numbers + numericStrings156 /**157 * Combinations of booleans and String representations thereof.158 */159 val booleanLikes = bools + booleanStrings160 /**161 * Values that are not Strings.162 */163 val nonStrings = mutableExhaustive { values - allStrings }164 /**165 * Values that are not arrays.166 */167 val nonArrays = mutableExhaustive {168 bools + doubles + ints + objects + longs + allStrings + explicitNull169 }170 /**171 * Values that are not objects.172 */173 val nonObjects = mutableExhaustive {174 bools + doubles + ints + arrays + longs + allStrings + explicitNull175 }176 /**177 * Values that are not int-likes.178 */179 val nonIntLikes = mutableExhaustive { values - intLikes }180 /**181 * Values that are not number-likes.182 */183 val nonNumberLikes = mutableExhaustive { values - numberLikes }184 /**185 * Values that are not boolean-likes.186 */187 val nonBooleanLikes = mutableExhaustive { values - booleanLikes }188}...

Full Screen

Full Screen

SectionTest.kt

Source:SectionTest.kt Github

copy

Full Screen

1/*2 * Copyright (c) 2018-2021 AnimatedLEDStrip3 *4 * Permission is hereby granted, free of charge, to any person obtaining a copy5 * of this software and associated documentation files (the "Software"), to deal6 * in the Software without restriction, including without limitation the rights7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell8 * copies of the Software, and to permit persons to whom the Software is9 * furnished to do so, subject to the following conditions:10 *11 * The above copyright notice and this permission notice shall be included in12 * all copies or substantial portions of the Software.13 *14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN20 * THE SOFTWARE.21 */22package animatedledstrip.test.leds.sectionmanagement23import animatedledstrip.communication.decodeJson24import animatedledstrip.communication.toUTF8String25import animatedledstrip.leds.emulation.createNewEmulatedStrip26import animatedledstrip.leds.sectionmanagement.LEDStripSectionManager27import animatedledstrip.leds.sectionmanagement.Section28import animatedledstrip.test.filteredStringArb29import io.kotest.assertions.throwables.shouldThrow30import io.kotest.core.spec.style.StringSpec31import io.kotest.matchers.collections.shouldHaveSize32import io.kotest.matchers.maps.shouldBeEmpty33import io.kotest.matchers.shouldBe34import io.kotest.matchers.types.shouldBeSameInstanceAs35import io.kotest.property.Arb36import io.kotest.property.Exhaustive37import io.kotest.property.arbitrary.filter38import io.kotest.property.arbitrary.int39import io.kotest.property.arbitrary.list40import io.kotest.property.arbitrary.string41import io.kotest.property.checkAll42import io.kotest.property.exhaustive.ints43class SectionTest : StringSpec(44 {45 val ledStrip = createNewEmulatedStrip(50)46 afterSpec {47 ledStrip.renderer.close()48 }49 "construction" {50 val section = Section()51 section.sections.shouldBeEmpty()52 section.subSections.shouldBeEmpty()53 section.name shouldBe ""54 section.numLEDs shouldBe 055 section.pixels.shouldHaveSize(0)56 shouldThrow<UninitializedPropertyAccessException> {57 section.stripManager58 }59 }60 "get physical index" {61 checkAll(Exhaustive.ints(0 until 49)) { s ->62 val section = LEDStripSectionManager(ledStrip).createSection("test:$s", s, 49)63 checkAll(Exhaustive.ints(0 until 49 - s)) { p ->64 section.getPhysicalIndex(p) shouldBe p + s65 }66 checkAll(Exhaustive.ints(0 until 49 - s)) { s2 ->67 val section2 = section.createSection("test:$s:$s2", s2, section.pixels.lastIndex)68 checkAll(Exhaustive.ints(0 until 49 - s - s2)) { p ->69 section2.getPhysicalIndex(p) shouldBe p + s + s270 }71 }72 checkAll(Arb.int().filter { it !in section.pixels.indices }) { p ->73 shouldThrow<IllegalArgumentException> {74 section.getPhysicalIndex(p)75 }76 }77 }78 }79 "get section" {80 val section = LEDStripSectionManager(ledStrip).fullStripSection81 section.getSection("test1") shouldBeSameInstanceAs section82 val sec = section.createSection("test1", 0, 15)83 section.getSection("test1") shouldBeSameInstanceAs sec84 section.getSection("test2") shouldBeSameInstanceAs section85 }86 "encode JSON" {87 checkAll(100, filteredStringArb, Arb.list(Arb.int(0..100000), 1..5000)) { n, p ->88 Section(n, p).jsonString() shouldBe89 """{"type":"Section","name":"$n","pixels":${90 p.toString().replace(" ", "")91 },"parentSectionName":""};;;"""92 }93 }94 "decode JSON" {95 checkAll(100, filteredStringArb, Arb.list(Arb.int(0..100000), 1..5000)) { n, p ->96 val json = """{"type":"Section","name":"$n","pixels":${97 p.toString().replace(" ", "")98 },"parentSectionName":""};;;"""99 val correctData = Section(n, p)100 val decodedData = json.decodeJson() as Section101 decodedData.name shouldBe correctData.name102 decodedData.numLEDs shouldBe correctData.numLEDs103 decodedData.pixels shouldBe correctData.pixels104 }105 }106 "encode and decode JSON" {107 checkAll(100, Arb.string(), Arb.list(Arb.int(0..100000), 1..5000)) { n, p ->108 val sec1 = Section(n, p)109 val secBytes = sec1.json()110 val sec2 = secBytes.toUTF8String().decodeJson() as Section111 sec2.name shouldBe sec1.name112 sec2.numLEDs shouldBe sec1.numLEDs113 sec2.pixels shouldBe sec1.pixels114 }115 }116 }117)...

Full Screen

Full Screen

BatchMigrationGenerator.kt

Source:BatchMigrationGenerator.kt Github

copy

Full Screen

1package liquibase.ext.generators2import io.kotest.property.Arb3import io.kotest.property.Exhaustive4import io.kotest.property.RandomSource5import io.kotest.property.arbitrary.arbitrary6import io.kotest.property.arbitrary.filter7import io.kotest.property.arbitrary.filterNot8import io.kotest.property.arbitrary.int9import io.kotest.property.arbitrary.list10import io.kotest.property.arbitrary.long11import io.kotest.property.arbitrary.map12import io.kotest.property.arbitrary.next13import io.kotest.property.arbitrary.orNull14import io.kotest.property.exhaustive.azstring15import io.kotest.property.exhaustive.exhaustive16import io.kotest.property.exhaustive.merge17import liquibase.ext.changes.BatchMigrationChange18import java.sql.RowIdLifetime19object BatchMigrationGenerator {20 val identifierGen = { min: Int -> Exhaustive.azstring(min..16).toArb() }21 val rowIdLifeTimeInvalidGenerator = listOf(22 RowIdLifetime.ROWID_UNSUPPORTED,23 RowIdLifetime.ROWID_VALID_OTHER,24 RowIdLifetime.ROWID_VALID_SESSION,25 RowIdLifetime.ROWID_VALID_TRANSACTION26 ).exhaustive()27 val rowIdLifeTimeGenerator = listOf(28 RowIdLifetime.ROWID_VALID_FOREVER,29 ).exhaustive().merge(rowIdLifeTimeInvalidGenerator)30 val validMigrationGenerator = arbitrary { rs: RandomSource ->31 val change = BatchMigrationChange()32 val colCount = Arb.int(1, 5).next(rs)33 val colGen = fixedColumnListNoDupsGenerator(colCount, colCount)34 change.tableName = identifierGen(1).next(rs)35 change.chunkSize = Arb.long(1L, 10000L).next(rs)36 val from = colGen.next(rs)37 val fromSet = from.toSet()38 change.fromColumns = from.toColumnList()39 // Make sure we do not have overlapping or crossing columns between from and to40 val to = colGen.filterNot { l -> fromSet.any { it in l.toSet() } }.next(rs)41 change.toColumns = to.toColumnList()42 change43 }44 val validMigrationWithSleepsGenerator = arbitrary { rs: RandomSource ->45 val mig = validMigrationGenerator.next(rs)46 mig.sleepTime = Arb.long(0L, 10000L).orNull().next(rs)47 mig48 }49 val sampleMigrationGenerator = arbitrary { rs: RandomSource ->50 val change = BatchMigrationChange()51 change.tableName = identifierGen(1).orNull().next(rs)52 change.chunkSize = Arb.long(-100L, 10000L).orNull().next(rs)53 val upperBound = Arb.int(0, 5).next(rs)54 val minBound = Arb.int(0, 5).filter { it <= upperBound }.next(rs)55 change.fromColumns = fixedColumnStringSequenceGenerator(minBound, upperBound).orNull().next(rs)56 change.toColumns = fixedColumnStringSequenceGenerator(minBound, upperBound).orNull().next(rs)57 change.sleepTime = Arb.long(-100L, 10000L).orNull().next(rs)58 change59 }60 val invalidMigrationGenerator = sampleMigrationGenerator.filter { c: BatchMigrationChange ->61 val simplePredicate = c.fromColumns.isNullOrEmpty() ||62 c.toColumns.isNullOrEmpty() || (c.chunkSize ?: -1L) <= 0L || c.sleepTime?.let { it < 0L } ?: false63 if (simplePredicate) return@filter true64 else {65 val from = c.fromColumns!!.split(",")66 val to = c.toColumns!!.split(",").toSet()67 // check whether from and to columns are equal somewhere or crossing68 // check whether any to column is in primary keys69 from.size != to.size || from.any { it in to }70 }71 }72 private fun List<String>.toColumnList(): String = joinToString(separator = ",") { it }73 private val fixedColumnListGenerator = { lowerBound: Int, inclusiveUpperBound: Int ->74 Arb.list(identifierGen(1), IntRange(lowerBound, inclusiveUpperBound))75 }76 private val fixedColumnListNoDupsGenerator = { lowerBound: Int, inclusiveUpperBound: Int ->77 fixedColumnListGenerator(lowerBound, inclusiveUpperBound).filterNot { l ->78 l.toSet().size != l.size79 }80 }81 private val fixedColumnStringSequenceGenerator = { lowerBound: Int, inclusiveUpperBound: Int ->82 fixedColumnListGenerator(lowerBound, inclusiveUpperBound).map { l -> l.joinToString(",") { it } }83 }84}...

Full Screen

Full Screen

ParserTest.kt

Source:ParserTest.kt Github

copy

Full Screen

1package dev.cyberdeck.lisp2import io.kotest.assertions.throwables.shouldThrow3import io.kotest.core.spec.style.StringSpec4import io.kotest.inspectors.forAll5import io.kotest.inspectors.forExactly6import io.kotest.matchers.collections.shouldHaveSize7import io.kotest.matchers.shouldBe8import io.kotest.matchers.string.shouldNotBeEmpty9import io.kotest.matchers.string.shouldNotContain10import io.kotest.matchers.types.shouldBeInstanceOf11import io.kotest.property.Exhaustive12import io.kotest.property.checkAll13import io.kotest.property.exhaustive.cartesian14import io.kotest.property.exhaustive.exhaustive15import io.kotest.property.exhaustive.merge16class ParserTest: StringSpec({17 val strings = listOf("\"hello\"", "\"hello world\"", "\"\"", "\")(\"", "\"()\"").exhaustive()18 val symbols = listOf("abc", "x", "x1", " a", " b").exhaustive()19 val atoms = symbols.merge(listOf("-1", "1", "1.0", "-1.0").exhaustive())20 val lists = Exhaustive.cartesian(atoms, atoms) { a, b -> listOf(a, b) }21 "parse token" {22 checkAll(symbols) { s ->23 val result = tokenize(s)24 result.forAll {25 it.shouldNotContain(" ")26 it.shouldNotBeEmpty()27 }28 result.forExactly(1) { it.shouldBe(s.trim()) }29 }30 }31 "parse with parens" {32 checkAll(symbols) { s ->33 val result = tokenize("($s)")34 result.forAll {35 it.shouldNotContain(" ")36 it.shouldNotBeEmpty()37 }38 result.forExactly(1) { it.shouldBe(s.trim()) }39 }40 }41 "parse with unbalanced parens" {42 checkAll(symbols) { s ->43 shouldThrow<SyntaxErr> {44 readFromTokens(tokenize("($s $s ($s ($s $s))")) // no closing paren45 }46 }47 }48 "parse strings" {49 val exp = readFromTokens(tokenize("\"well this is silly\""))50 exp.shouldBe(LString("well this is silly"))51 }52 "parse lists of strings" {53 checkAll(strings) { str ->54 val bare = str.substring(1, str.length - 1)55 val exp = readFromTokens(tokenize("($str ($str $str))"))56 exp.shouldBe(listExp(LString(bare), listExp(LString(bare), LString(bare))))57 }58 }59 "parse complex expressions" {60 val tokens = tokenize("(begin (define r 10.0) (* pi (* r r)))")61 tokens.shouldBe(listOf("(", "begin", "(", "define", "r", "10.0", ")", "(", "*", "pi", "(", "*", "r", "r", ")", ")", ")"))62 }63 "readFromTokens fails if empty" {64 shouldThrow<SyntaxErr> {65 readFromTokens(emptyList())66 }67 }68 "readFromTokens returns int" {69 checkAll<Int> { i ->70 readFromTokens(listOf(i.toString())).shouldBe(Num(i))71 }72 }73 "readFromTokens returns float" {74 checkAll<Float> { f ->75 readFromTokens(listOf(f.toString())).shouldBe(Num(f))76 }77 }78 "readFromTokens returns boolean" {79 checkAll<Boolean> { b ->80 readFromTokens(listOf(b.toString())).shouldBe(Bool(b))81 }82 }83 "readFromTokens returns string" {84 checkAll(strings) { str ->85 readFromTokens(listOf(str)).shouldBe(LString(str.substring(1, str.length - 1)))86 }87 }88 "readFromTokens returns symbol" {89 checkAll(symbols) { s ->90 readFromTokens(listOf(s)).shouldBe(Symbol(s))91 }92 }93 "readFromTokens fails on unmatched closing paren" {94 shouldThrow<SyntaxErr> {95 readFromTokens(listOf(")"))96 }97 }98 "readFromTokens returns list of atoms" {99 checkAll(lists) { list ->100 readFromTokens(listOf("(") + list + ")")101 .shouldBeInstanceOf<L>()102 .list.shouldHaveSize(list.size)103 .forAll { it.shouldBeInstanceOf<Atom>() }104 }105 }106})...

Full Screen

Full Screen

ItemGens.kt

Source:ItemGens.kt Github

copy

Full Screen

1package dev.adamko.gildedrose.testdata2import com.gildedrose.Item3import dev.adamko.config.KotestConfig.Companion.intEdgecases4import dev.adamko.config.KotestConfig.Companion.mergeAll5import io.kotest.property.Arb6import io.kotest.property.Gen7import io.kotest.property.arbitrary.alphanumeric8import io.kotest.property.arbitrary.bind9import io.kotest.property.arbitrary.filterNot10import io.kotest.property.arbitrary.map11import io.kotest.property.arbitrary.string12import io.kotest.property.arbitrary.withEdgecases13import io.kotest.property.exhaustive.exhaustive14object ItemGens {15 object Names {16 val regular = Arb.string(10, Arb.alphanumeric()).withEdgecases(17 "+5 Dexterity Vest",18 "Elixir of the Mongoose",19 )20 val aged = listOf("Aged Brie").exhaustive()21 val tickets = listOf("Backstage passes to a TAFKAL80ETC concert").exhaustive()22 val legendary = listOf("Sulfuras, Hand of Ragnaros").exhaustive()23 val conjured = listOf(regular, aged, tickets, legendary).mergeAll().map { "Conjured $it" }24 val all = listOf(regular, aged, tickets, conjured, legendary).mergeAll()25 val nonLegendary = listOf(regular, aged, tickets, conjured).mergeAll()26 }27 object SellIn {28 /**29 * Edgecases for the minimum and maximum values, as well as some that30 * are centered around the expiration date of 0.31 */32 private val edgecases: List<Int> = (-2..2) + (Int.MAX_VALUE - 1) + (Int.MIN_VALUE + 1)33 // note- ignore integer overflow for now34 val nonExpired = Arb.intEdgecases(1, Int.MAX_VALUE - 1, edgecases)35 val expired = Arb.intEdgecases(Int.MIN_VALUE + 1, 0, edgecases)36 val any = Arb.intEdgecases(Int.MIN_VALUE + 1 until Int.MAX_VALUE, edgecases)37 }38 object Quality {39 val regularValidRange = 0..5040 /** Some additional edgecases around the min/max quality range */41 private val edgecases: List<Int> =42 regularValidRange.first.let { (it - 3)..(it + 3) } +43 regularValidRange.last.let { (it - 3)..(it + 3) }44 val any = Arb.intEdgecases(Int.MIN_VALUE + 1 until Int.MAX_VALUE, edgecases)45 val validRegular = Arb.intEdgecases(regularValidRange, edgecases)46 // note- ignore integer overflow for now47 val invalidRegular = any.filterNot { it in regularValidRange }48 }49 object Binds {50 fun itemArb(51 nameGen: Gen<String> = Names.all,52 sellInGen: Gen<Int> = SellIn.any,53 qualityGen: Gen<Int> = Quality.any,54 ) = Arb.bind(nameGen, sellInGen, qualityGen) { name, sellIn, quality ->55 Item(name, sellIn, quality)56 }57 }58}...

Full Screen

Full Screen

MergeTest.kt

Source:MergeTest.kt Github

copy

Full Screen

1package com.sksamuel.kotest.property.exhaustive2import io.kotest.assertions.throwables.shouldNotThrowAny3import io.kotest.core.spec.style.FunSpec4import io.kotest.matchers.shouldBe5import io.kotest.property.Arb6import io.kotest.property.RandomSource7import io.kotest.property.arbitrary.merge8import io.kotest.property.arbitrary.of9import io.kotest.property.arbitrary.single10import io.kotest.property.exhaustive.exhaustive11import io.kotest.property.exhaustive.merge12private sealed class Common {13 internal data class Foo(val value: Int) : Common()14 internal data class Bar(val value: Int) : Common()15}16class MergeTest : FunSpec({17 test("merge two exhaustive gens where one is a subtype of the other") {18 listOf(1, 2, 3).exhaustive().merge(listOf(4, 5, 6).exhaustive()).values shouldBe listOf(1, 4, 2, 5, 3, 6)19 }20 test("merge two exhaustive gens where neither is a subtype of the other") {21 val firstGen = listOf(Common.Foo(1), Common.Foo(2), Common.Foo(3)).exhaustive()22 val secondGen = listOf(Common.Bar(4), Common.Bar(5), Common.Bar(6)).exhaustive()23 firstGen.merge(secondGen).values shouldBe listOf(24 Common.Foo(1),25 Common.Bar(4),26 Common.Foo(2),27 Common.Bar(5),28 Common.Foo(3),29 Common.Bar(6)30 )31 }32 test("Arb.merge composition should not exhaust call stack") {33 var arb: Arb<Int> = Arb.of(0)34 repeat(100) {35 arb = arb.merge(Arb.of(1))36 }37 val result = shouldNotThrowAny { arb.single(RandomSource.seeded(1234L)) }38 result shouldBe 139 }40})...

Full Screen

Full Screen

GeneratorSpec.kt

Source:GeneratorSpec.kt Github

copy

Full Screen

1package ru.iopump.qa.sample.property2import io.kotest.core.spec.style.FreeSpec3import io.kotest.property.Arb4import io.kotest.property.Exhaustive5import io.kotest.property.arbitrary.*6import io.kotest.property.exhaustive.enum7import io.kotest.property.exhaustive.ints8import io.kotest.property.exhaustive.merge9import io.kotest.property.exhaustive.times10import org.slf4j.event.Level11/** For string generator with leading zero */12/*1*/val numberCodepoint: Arb<Codepoint> = Arb.int(0x0030..0x0039)13 .map { Codepoint(it) }14/** For english string generator */15/*2*/val engCodepoint: Arb<Codepoint> = Arb.int('a'.toInt()..'z'.toInt())16 .merge(Arb.int('A'.toInt()..'Z'.toInt()))17 .map { Codepoint(it) }18class GeneratorSpec : FreeSpec() {19 init {20 "/*3*/ random number supported leading zero" {21 Arb.string(10, numberCodepoint).next()22 .also(::println)23 }24 "/*4*/ random english string" {25 Arb.string(10, engCodepoint).orNull(0.5).next()26 .also(::println)27 }28 "/*5*/ random russian mobile number" {29 Arb.stringPattern("+7\\(\\d{3}\\)\\d{3}-\\d{2}-\\d{2}").next()30 .also(::println)31 }32 "/*6*/ exhaustive collection and enum multiply" {33 Exhaustive.ints(1..5).times(Exhaustive.enum<Level>()).values34 .also(::println)35 }36 "/*7*/ exhaustive collection and enum merge" {37 Exhaustive.ints(1..5).merge(Exhaustive.enum<Level>()).values38 .also(::println)39 }40 }41}...

Full Screen

Full Screen

option.kt

Source:option.kt Github

copy

Full Screen

1package io.kotest.property.arrow2import arrow.core.None3import arrow.core.Option4import arrow.core.Some5import arrow.core.some6import io.kotest.property.Arb7import io.kotest.property.Exhaustive8import io.kotest.property.arbitrary.constant9import io.kotest.property.arbitrary.map10import io.kotest.property.arbitrary.merge11import io.kotest.property.exhaustive.exhaustive12/**13 * Returns an Exhaustive that contains a None and a Some with the given value14 */15fun <A> Exhaustive.Companion.option(a: A) = exhaustive(listOf(None, Some(a)))16fun <A> Exhaustive.Companion.none() = exhaustive(listOf(None))17/**18 * Wraps each element generated by the given Arb in a Some.19 */20fun <A> Arb.Companion.some(arb: Arb<A>): Arb<Option<A>> = arb.map { it.some() }21fun <A> Arb.Companion.none(): Arb<Option<A>> = Arb.constant(None)22fun <A> Arb.Companion.option(arb: Arb<A>): Arb<Option<A>> = some(arb).merge(none())...

Full Screen

Full Screen

Exhaustive.merge

Using AI Code Generation

copy

Full Screen

1val list1 = listOf(1, 2, 3)2val list2 = listOf(4, 5, 6)3val list3 = listOf(7, 8, 9)4val merged = Exhaustive.merge(list1, list2, list3)5merged.values shouldBe listOf(1, 2, 3, 4, 5, 6, 7, 8, 9)6val list1 = listOf(1, 2, 3)7val list2 = listOf(4, 5, 6)8val list3 = listOf(7, 8, 9)9val merged = Exhaustive.merge(list1, list2, list3)10merged.values shouldBe listOf(1, 2, 3, 4, 5, 6, 7, 8, 9)11val list1 = listOf(1, 2, 3)12val list2 = listOf(4, 5, 6)13val list3 = listOf(7, 8, 9)14val merged = Exhaustive.merge(list1, list2, list3)15merged.values shouldBe listOf(1, 2, 3, 4, 5, 6, 7, 8, 9)16val list1 = listOf(1, 2, 3)17val list2 = listOf(4, 5, 6)18val list3 = listOf(7, 8, 9)19val merged = Exhaustive.merge(list1, list2, list3)20merged.values shouldBe listOf(1, 2, 3, 4, 5, 6, 7, 8, 9)21val list1 = listOf(1, 2, 3)22val list2 = listOf(4, 5, 6)23val list3 = listOf(7, 8, 9)24val merged = Exhaustive.merge(list1, list2, list3)

Full Screen

Full Screen

Exhaustive.merge

Using AI Code Generation

copy

Full Screen

1Exhaustive.merge(Exhaustive.ints(0, 10), Exhaustive.ints(20, 30))2Exhaustive.merge(Exhaustive.ints(0, 10), Exhaustive.ints(20, 30), Exhaustive.ints(40, 50))3Exhaustive.merge(Exhaustive.ints(0, 10), Exhaustive.ints(20, 30), Exhaustive.ints(40, 50), Exhaustive.ints(60, 70))4Exhaustive.merge(Exhaustive.ints(0, 10), Exhaustive.ints(20, 30), Exhaustive.ints(40, 50), Exhaustive.ints(60, 70), Exhaustive.ints(80, 90))5Exhaustive.merge(Exhaustive.ints(0, 10), Exhaustive.ints(20, 30), Exhaustive.ints(40, 50), Exhaustive.ints(60, 70), Exhaustive.ints(80, 90), Exhaustive.ints(100, 110))6Exhaustive.merge(Exhaustive.ints(0, 10), Exhaustive.ints(20, 30), Exhaustive.ints(40, 50), Exhaustive.ints(60, 70), Exhaustive.ints(80, 90), Exhaustive.ints(100, 110), Exhaustive.ints(120, 130))7Exhaustive.merge(Exhaustive.ints(0, 10), Exhaustive.ints(20, 30), Exhaustive.ints(40, 50), Exhaustive.ints(60, 70), Exhaustive.ints(80, 90), Exhaustive.ints

Full Screen

Full Screen

Exhaustive.merge

Using AI Code Generation

copy

Full Screen

1 fun <T> exhaustiveMerge(exhaustiveA: Exhaustive<T>, exhaustiveB: Exhaustive<T>): Exhaustive<T> {2 return Exhaustive.merge(exhaustiveA, exhaustiveB)3 }4 fun <T> exhaustiveMerge(exhaustiveA: Exhaustive<T>, exhaustiveB: Exhaustive<T>, exhaustiveC: Exhaustive<T>): Exhaustive<T> {5 return Exhaustive.merge(exhaustiveA, exhaustiveB, exhaustiveC)6 }

Full Screen

Full Screen

Exhaustive.merge

Using AI Code Generation

copy

Full Screen

1val exhaustive = Exhaustive.ints(1, 10)2val mergedExhaustive = exhaustive.merge(exhaustive)3val exhaustive = Exhaustive.ints(1, 10)4val mergedExhaustive = exhaustive.merge(exhaustive)5val exhaustive = Exhaustive.ints(1, 10)6val mergedExhaustive = exhaustive.merge(exhaustive)7val exhaustive = Exhaustive.ints(1, 10)8val mergedExhaustive = exhaustive.merge(exhaustive)9val exhaustive = Exhaustive.ints(1, 10)10val mergedExhaustive = exhaustive.merge(exhaustive)

Full Screen

Full Screen

Exhaustive.merge

Using AI Code Generation

copy

Full Screen

1val exhaustive = Exhaustive . merge ( listOf ( 1 , 2 , 3 ) , listOf ( 4 , 5 , 6 ) ) 2val exhaustive = Exhaustive . merge ( listOf ( 1 , 2 , 3 ) , listOf ( 4 , 5 , 6 ) ) 3val exhaustive = Exhaustive . merge ( listOf ( 1 , 2 , 3 ) , listOf ( 4 , 5 , 6 ) ) 4val exhaustive = Exhaustive . merge ( listOf ( 1 , 2 , 3 ) , listOf ( 4 , 5 , 6 ) ) 5val exhaustive = Exhaustive . merge ( listOf ( 1 , 2 , 3 ) , listOf ( 4 , 5 , 6 ) ) 6val exhaustive = Exhaustive . merge ( listOf ( 1 , 2 , 3 ) , listOf ( 4 , 5 , 6 ) ) 7 println ( exhaustive . values )

Full Screen

Full Screen

Exhaustive.merge

Using AI Code Generation

copy

Full Screen

1val exhaustive = Exhaustive .merge ( Exhaustive .ints ( 1 , 10 ), Exhaustive .ints ( 20 , 30 ))2val exhaustive = Exhaustive .merge ( Exhaustive .ints ( 1 , 10 ), Exhaustive .ints ( 20 , 30 ))3val exhaustive = Exhaustive .merge ( Exhaustive .ints ( 1 , 10 ), Exhaustive .ints ( 20 , 30 ))4val exhaustive = Exhaustive .merge ( Exhaustive .ints ( 1 , 10 ), Exhaustive .ints ( 20 , 30 ))5val exhaustive = Exhaustive .merge ( Exhaustive .ints ( 1 , 10 ), Exhaustive .ints ( 20 , 30 ))6val exhaustive = Exhaustive .merge ( Exhaustive .ints ( 1 , 10 ), Exhaustive .ints ( 20 , 30 ))7val exhaustive = Exhaustive .merge ( Exhaustive .ints ( 1 , 10 ), Exhaustive .ints ( 20 , 30 ))8val exhaustive = Exhaustive .merge ( Exhaustive .ints ( 1 , 10 ), Exhaustive .ints ( 20 , 30 ))9val exhaustive = Exhaustive .merge ( Exhaustive .ints ( 1 , 10 ), Exhaustive .ints ( 20 , 30 ))

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