How to use sample method of io.kotest.property.arbitrary.map class

Best Kotest code snippet using io.kotest.property.arbitrary.map.sample

InterceptablePrintStreamProperty.kt

Source:InterceptablePrintStreamProperty.kt Github

copy

Full Screen

...63 val charSequenceGenerator = Arb.string()64 val charGenerator = Arb.char()65 val byteArrayGenerator = Arb.string().map { it.toByteArray() }66 val charArrayGenerator = Arb.string().map { it.toCharArray() }67 val booleanValue = booleanGenerator.sample(rs).value68 val intValue = intGenerator.sample(rs).value69 val doubleValue = doubleGenerator.sample(rs).value70 val longValue = longGenerator.sample(rs).value71 val floatValue = floatGenerator.sample(rs).value72 val stringValue = stringGenerator.sample(rs).value73 val charSequenceValue = charSequenceGenerator.sample(rs).value74 val charValue = charGenerator.sample(rs).value75 val byteArrayValue = byteArrayGenerator.sample(rs).value76 val charArrayValue = charArrayGenerator.sample(rs).value77 val objectValue = Object()78 val result: PrintStreamAction =79 when (actionNameGenerator.sample(rs).value) {80 PrintStreamActionName.PRINT_INT ->81 PrintStreamAction("print int $intValue") { print(intValue) }82 PrintStreamActionName.PRINT_DOUBLE ->83 PrintStreamAction("print double $doubleValue") { print(doubleValue) }84 PrintStreamActionName.PRINT_LONG ->85 PrintStreamAction("print long $longValue") { print(longValue) }86 PRINT_FLOAT ->87 PrintStreamAction("print float $floatValue") { print(floatValue) }88 PRINT_STRING ->89 PrintStreamAction("print string $stringValue") { print(stringValue) }90 PRINT_BOOLEAN ->91 PrintStreamAction("print boolean $booleanValue") { print(booleanValue) }92 PRINT_OBJECT -> PrintStreamAction("print object") { print(objectValue) }93 WRITE_INT -> PrintStreamAction("write int $intValue") { write(intValue) }94 WRITE_BYTE_ARRAY ->95 PrintStreamAction("write byte array $byteArrayValue") {96 write(byteArrayValue)97 }98 WRITE_BYTE_ARRAY_WITH_OFFSETS ->99 PrintStreamAction("write byte array $byteArrayValue with offsets") {100 write(byteArrayValue, 0, byteArrayValue.size)101 }102 PRINTLN_INT ->103 PrintStreamAction("println int $intValue") { println(intValue) }104 PRINTLN_DOUBLE ->105 PrintStreamAction("println double $doubleValue") {106 println(doubleValue)107 }108 PRINTLN_LONG ->109 PrintStreamAction("println long $longValue") { println(longValue) }110 PRINTLN_FLOAT ->111 PrintStreamAction("println float $floatValue") { println(floatValue) }112 PRINTLN_STRING ->113 PrintStreamAction("println string $stringValue") {114 println(stringValue)115 }116 PRINTLN_BOOLEAN ->117 PrintStreamAction("println boolean $booleanValue") {118 println(booleanValue)119 }120 PRINTLN_CHAR_ARRAY ->121 PrintStreamAction("println char array $charArrayValue") {122 println(charArrayValue)123 }124 PRINTLN_OBJECT ->125 PrintStreamAction("println object") { println(objectValue) }126 APPEND_CHAR ->127 PrintStreamAction("append char $charValue") { append(charValue) }128 APPEND_CHAR_SEQUENCE ->129 PrintStreamAction("append char sequence $charSequenceValue") {130 append(charSequenceValue)131 }132 APPEND_CHAR_SEQUENCE_WITH_RANGE ->133 PrintStreamAction("append char sequence $charSequenceValue with range")134 { append(charSequenceValue, 0, charSequenceValue.length) }135 FORMAT ->136 PrintStreamAction("format int $intValue") { format("%d", intValue) }137 PrintStreamActionName.PRINTF ->138 PrintStreamAction("printf int $intValue") { printf("%d", intValue) }139 CHECK_ERROR -> PrintStreamAction("check error") { checkError() }140 FLUSH -> PrintStreamAction("flush") { flush() }141 CLOSE -> PrintStreamAction("close") { close() }142 }143 result144 }145 val arbActions: Arb<PrintStreamActions> =146 arbitrary { rs ->147 val numberOfActions = rs.random.nextInt(0, 8)148 val actions = arbAction.samples(rs).take(numberOfActions).map { it.value }.toList()149 PrintStreamActions(actions)150 }151 "actions are transparent" - {152 checkAll(arbActions) { actions -> compareResultsOf(actions) }153 }154 }155 private enum class PrintStreamActionName {156 PRINT_INT,157 PRINT_DOUBLE,158 PRINT_LONG,159 PRINT_FLOAT,160 PRINT_STRING,161 PRINT_BOOLEAN,162 PRINT_OBJECT,...

Full Screen

Full Screen

Arb.kt

Source:Arb.kt Github

copy

Full Screen

1package arrow.fx.coroutines.stream2import io.kotest.property.Arb3import io.kotest.property.RandomSource4import io.kotest.property.Sample5import io.kotest.property.Shrinker6import io.kotest.property.arbitrary.arb7import io.kotest.property.arbitrary.bool8import io.kotest.property.arbitrary.byte9import io.kotest.property.arbitrary.choice10import io.kotest.property.arbitrary.choose11import io.kotest.property.arbitrary.double12import io.kotest.property.arbitrary.float13import io.kotest.property.arbitrary.int14import io.kotest.property.arbitrary.list15import io.kotest.property.arbitrary.long16import io.kotest.property.arbitrary.map17import io.kotest.property.arbitrary.set18import io.kotest.property.arbitrary.short19import kotlin.random.nextInt20@JvmOverloads21inline fun <reified A> Arb.Companion.array(22 gen: Arb<A>,23 range: IntRange = 0..10024): Arb<Array<A>> {25 check(!range.isEmpty())26 check(range.first >= 0)27 return arb(edgecases = listOf(emptyArray<A>()) + gen.edgecases().map { arrayOf(it) }) {28 sequence {29 val genIter = gen.generate(it).iterator()30 while (true) {31 val targetSize = it.random.nextInt(range)32 val list = ArrayList<A>(targetSize)33 while (list.size < targetSize && genIter.hasNext()) {34 list.add(genIter.next().value)35 }36 check(list.size == targetSize)37 yield(list.toArray() as Array<A>)38 }39 }40 }41}42@PublishedApi43internal fun <A, B> arrayChunkGenerator(44 arb: Arb<A>,45 shrinker: Shrinker<B>,46 range: IntRange = 0..10,47 build: (values: List<A>, offset: Int, length: Int) -> B48): Arb<B> {49 check(!range.isEmpty())50 check(range.first >= 0)51 val edgecases =52 arb.edgecases().map { a -> build(listOf(a), 0, 1) } + build(emptyList(), 0, 0)53 return arb(edgecases, shrinker) {54 val genIter = arb.generate(it).iterator()55 sequence {56 while (true) {57 val targetSize = it.random.nextInt(range)58 val list = ArrayList<A>(targetSize)59 while (list.size < targetSize && genIter.hasNext()) {60 list.add(genIter.next().value)61 }62 val offset = (0..list.size).random(it.random)63 val length = (0..(list.size - offset)).random(it.random)64 yield(build(list, offset, length))65 }66 }67 }68}69class ChunkShrinker<A> : Shrinker<Chunk<A>> {70 override fun shrink(value: Chunk<A>): List<Chunk<A>> =71 if (value.isEmpty()) emptyList()72 else listOf(73 Chunk.empty(),74 value.takeLast(1),75 value.take(value.size() / 3),76 value.take(value.size() / 2),77 value.take(value.size() * 2 / 3),78 value.dropLast(1)79 )80}81inline fun <reified A> Arb.Companion.chunk(arb: Arb<A>): Arb<Chunk<A>> =82 object : Arb<Chunk<A>>() {83 override fun edgecases(): List<Chunk<A>> =84 listOf(Chunk.empty<A>()) + arb.edgecases().map { Chunk(it) }85 override fun values(rs: RandomSource): Sequence<Sample<Chunk<A>>> =86 Arb.choose(87 5 to arb.map { Chunk.just(it) },88 10 to Arb.list(arb, 0..20).map { Chunk.iterable(it) },89 10 to Arb.set(arb, 0..20).map { Chunk.iterable(it) },90 10 to Arb.array(arb, 0..20).map { Chunk.array(it) },91 10 to Arb.boxedChunk(arb)92 ).values(rs)93 }94inline fun <reified A> Arb.Companion.boxedChunk(arb: Arb<A>): Arb<Chunk<A>> =95 object : Arb<Chunk<A>>() {96 override fun edgecases(): List<Chunk<A>> =97 listOf(Chunk.empty<A>()) + arb.edgecases().map { Chunk(it) }98 override fun values(rs: RandomSource): Sequence<Sample<Chunk<A>>> =99 arrayChunkGenerator(arb, ChunkShrinker()) { values, offset, length ->100 Chunk.boxed(values.toTypedArray(), offset, length)101 }.values(rs)102 }103fun Arb.Companion.booleanChunk(): Arb<Chunk<Boolean>> =104 object : Arb<Chunk<Boolean>>() {105 override fun edgecases(): List<Chunk<Boolean>> =106 listOf(Chunk.empty<Boolean>()) + Arb.bool().edgecases().map { Chunk(it) }107 override fun values(rs: RandomSource): Sequence<Sample<Chunk<Boolean>>> =108 Arb.choice(109 arrayChunkGenerator(Arb.bool(), ChunkShrinker()) { values, offset, length ->110 Chunk.booleans(values.toBooleanArray(), offset, length)111 },112 arrayChunkGenerator(Arb.bool(), ChunkShrinker()) { values, _, _ ->113 Chunk.array(values.toTypedArray())114 }115 ).values(rs)116 }117fun Arb.Companion.byteChunk(): Arb<Chunk<Byte>> =118 object : Arb<Chunk<Byte>>() {119 override fun edgecases(): List<Chunk<Byte>> =120 listOf(Chunk.empty<Byte>()) + Arb.byte().edgecases().map { Chunk(it) }121 override fun values(rs: RandomSource): Sequence<Sample<Chunk<Byte>>> =122 Arb.choice(123 arrayChunkGenerator(Arb.byte(), ChunkShrinker()) { values, offset, length ->124 Chunk.bytes(values.toByteArray(), offset, length)125 },126 arrayChunkGenerator(Arb.byte(), ChunkShrinker()) { values, _, _ ->127 Chunk.array(values.toTypedArray())128 }129 ).values(rs)130 }131fun Arb.Companion.intChunk(): Arb<Chunk<Int>> =132 object : Arb<Chunk<Int>>() {133 override fun edgecases(): List<Chunk<Int>> =134 listOf(Chunk.empty<Int>()) + Arb.int().edgecases().map { Chunk(it) }135 override fun values(rs: RandomSource): Sequence<Sample<Chunk<Int>>> =136 Arb.choice(137 arrayChunkGenerator(Arb.int(), ChunkShrinker()) { values, offset, length ->138 Chunk.ints(values.toIntArray(), offset, length)139 },140 arrayChunkGenerator(Arb.int(), ChunkShrinker()) { values, _, _ ->141 Chunk.array(values.toTypedArray())142 }143 ).values(rs)144 }145fun Arb.Companion.longChunk(): Arb<Chunk<Long>> =146 object : Arb<Chunk<Long>>() {147 override fun edgecases(): List<Chunk<Long>> =148 listOf(Chunk.empty<Long>()) + Arb.long().edgecases().map { Chunk(it) }149 override fun values(rs: RandomSource): Sequence<Sample<Chunk<Long>>> =150 Arb.choice(151 arrayChunkGenerator(Arb.long(), ChunkShrinker()) { values, offset, length ->152 Chunk.longs(values.toLongArray(), offset, length)153 },154 arrayChunkGenerator(Arb.long(), ChunkShrinker()) { values, _, _ ->155 Chunk.array(values.toTypedArray())156 }157 ).values(rs)158 }159fun Arb.Companion.doubleChunk(): Arb<Chunk<Double>> =160 object : Arb<Chunk<Double>>() {161 override fun edgecases(): List<Chunk<Double>> =162 listOf(Chunk.empty<Double>()) + Arb.double().edgecases().map { Chunk(it) }163 override fun values(rs: RandomSource): Sequence<Sample<Chunk<Double>>> =164 Arb.choice(165 arrayChunkGenerator(Arb.double(), ChunkShrinker()) { values, offset, length ->166 Chunk.doubles(values.toDoubleArray(), offset, length)167 },168 arrayChunkGenerator(Arb.double(), ChunkShrinker()) { values, _, _ ->169 Chunk.array(values.toTypedArray())170 }171 ).values(rs)172 }173fun Arb.Companion.floatChunk(): Arb<Chunk<Float>> =174 object : Arb<Chunk<Float>>() {175 override fun edgecases(): List<Chunk<Float>> =176 listOf(Chunk.empty<Float>()) + Arb.float().edgecases().map { Chunk(it) }177 override fun values(rs: RandomSource): Sequence<Sample<Chunk<Float>>> =178 Arb.choice(179 arrayChunkGenerator(Arb.float(), ChunkShrinker()) { values, offset, length ->180 Chunk.floats(values.toFloatArray(), offset, length)181 },182 arrayChunkGenerator(Arb.float(), ChunkShrinker()) { values, _, _ ->183 Chunk.array(values.toTypedArray())184 }185 ).values(rs)186 }187fun Arb.Companion.shortChunk(): Arb<Chunk<Short>> =188 object : Arb<Chunk<Short>>() {189 override fun edgecases(): List<Chunk<Short>> =190 listOf(Chunk.empty<Short>()) + Arb.short().edgecases().map { Chunk(it) }191 override fun values(rs: RandomSource): Sequence<Sample<Chunk<Short>>> =192 Arb.choice(193 arrayChunkGenerator(Arb.short(), ChunkShrinker()) { values, offset, length ->194 Chunk.shorts(values.toShortArray(), offset, length)195 },196 arrayChunkGenerator(Arb.short(), ChunkShrinker()) { values, _, _ ->197 Chunk.array(values.toTypedArray())198 }199 ).values(rs)200 }...

Full Screen

Full Screen

EntitySerializerTest.kt

Source:EntitySerializerTest.kt Github

copy

Full Screen

1/*Copyright 2021 Mecharex Kft.2This file is part of the logikaldb library.3The logikaldb library is free software: you can redistribute it and/or modify4it under the terms of the GNU Lesser General Public License as published by5the Free Software Foundation, either version 3 of the License, or6(at your option) any later version.7The logikaldb library is distributed in the hope that it will be useful,8but WITHOUT ANY WARRANTY; without even the implied warranty of9MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the10GNU Lesser General Public License for more details.11You should have received a copy of the GNU Lesser General Public License12along with the logikaldb library. If not, see <http://www.gnu.org/licenses/>.*/13package com.logikaldb.serializer14import com.logikaldb.entity.AndEntity15import com.logikaldb.entity.ConstraintEntity16import com.logikaldb.entity.ConstraintFunEntity17import com.logikaldb.entity.EqualEntity18import com.logikaldb.entity.FieldEntity19import com.logikaldb.entity.OrEntity20import com.logikaldb.entity.ValueEntity21import com.logikaldb.logikal.Logikal.equal22import io.kotest.core.spec.style.StringSpec23import io.kotest.property.Arb24import io.kotest.property.RandomSource25import io.kotest.property.Sample26import io.kotest.property.arbitrary.arb27import io.kotest.property.arbitrary.double28import io.kotest.property.arbitrary.int29import io.kotest.property.arbitrary.list30import io.kotest.property.arbitrary.map31import io.kotest.property.arbitrary.string32import io.kotest.property.forAll33class EntitySerializerTest : StringSpec({34 val underTest = EntitySerializer()35 fun createEqualEntity(randomPair: Pair<Sample<String>, Sample<Any>>): EqualEntity {36 return EqualEntity(FieldEntity(randomPair.first.value, String::class.java), ValueEntity(randomPair.second.value))37 }38 fun anyRandomValues(randomSource: RandomSource): Sequence<Sample<Any>> {39 val randomStrings = Arb.string().values(randomSource)40 val randomIntegers = Arb.int().values(randomSource)41 val randomDoubles = Arb.double().values(randomSource)42 return randomStrings + randomIntegers + randomDoubles43 }44 "A serialized and deserialized EqualEntity must be the same as the original entity" {45 val equalConstraintEntityArb = arb { randomSource ->46 val randomFields = Arb.string().values(randomSource)47 val randomValues = anyRandomValues(randomSource)48 randomFields.zip(randomValues)49 .map(::createEqualEntity)50 .map { ConstraintEntity(it) }51 }52 forAll(equalConstraintEntityArb) { equalConstraintEntity ->53 underTest.deserialize(underTest.serialize(equalConstraintEntity)) == equalConstraintEntity54 }55 }56 "A serialized and deserialized ConstraintEntity is not the same when the constraint fun is defined" {57 val constraintConstraintEntityArb = arb { randomSource ->58 val randomConstraints = Arb.string().values(randomSource)59 val randomParameters = Arb.list(Arb.string())60 .map { parameterNames -> parameterNames.map { FieldEntity(it, String::class.java) } }61 .values(randomSource)62 randomConstraints.zip(randomParameters)63 .map { ConstraintFunEntity(equal(1, 1)) }64 .map { ConstraintEntity(it) }65 }66 forAll(constraintConstraintEntityArb) { constraintConstraintEntity ->67 val convertedConstraintConstraintEntity = underTest.deserialize(underTest.serialize(constraintConstraintEntity))68 convertedConstraintConstraintEntity != constraintConstraintEntity69 }70 }71 "A serialized and deserialized AndEntity must be the same as the original entity" {72 val equalEntityArb = arb { randomSource ->73 val randomFields = Arb.string().values(randomSource)74 val randomValues = anyRandomValues(randomSource)75 randomFields.zip(randomValues)76 .map(::createEqualEntity)77 }78 val andConstraintEntityArb = arb { randomSource ->79 Arb.list(equalEntityArb, IntRange(0, 100)).values(randomSource)80 .map { AndEntity(it.value) }81 .map { ConstraintEntity(it) }82 }83 forAll(andConstraintEntityArb) { andConstraintEntity ->84 underTest.deserialize(underTest.serialize(andConstraintEntity)) == andConstraintEntity85 }86 }87 "A serialized and deserialized OrEntity must be the same as the original entity" {88 val equalEntityArb = arb { randomSource ->89 val randomFields = Arb.string().values(randomSource)90 val randomValues = anyRandomValues(randomSource)91 randomFields.zip(randomValues)92 .map(::createEqualEntity)93 }94 val orConstraintEntityArb = arb { randomSource ->95 Arb.list(equalEntityArb, IntRange(0, 100)).values(randomSource)96 .map { OrEntity(it.value) }97 .map { ConstraintEntity(it) }98 }99 forAll(orConstraintEntityArb) { orConstraintEntity ->100 underTest.deserialize(underTest.serialize(orConstraintEntity)) == orConstraintEntity101 }102 }103})...

Full Screen

Full Screen

BatchMigrationGenerator.kt

Source:BatchMigrationGenerator.kt Github

copy

Full Screen

...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))...

Full Screen

Full Screen

TobogganTrajectoryTest.kt

Source:TobogganTrajectoryTest.kt Github

copy

Full Screen

1import io.kotest.core.spec.style.DescribeSpec2import io.kotest.matchers.shouldBe3import io.kotest.property.Arb4import io.kotest.property.arbitrary.list5import io.kotest.property.arbitrary.map6import io.kotest.property.arbitrary.positiveInts7import io.kotest.property.arbitrary.stringPattern8import io.kotest.property.checkAll9import java.io.File10class TobogganTrajectoryTest : DescribeSpec({11 val t = TobogganTrajectory()12 describe("Toboggan Trajectory") {13 context("Sample input") {14 val input: List<String> = File("input.txt").readLines()15 val actual = t.tobogganTrajectory(input)16 actual shouldBe 20717 }18 context("Grid of no trees") {19 it("Returns 0") {20 checkAll(Arb.positiveInts(100).map { (".".repeat(it) + "\n").repeat(it) }) { g ->21 t.tobogganTrajectory(g.split("\n").dropLast(1)) shouldBe 022 }23 }24 }25 context("Grid of only trees") {26 it("Returns height of grid") {27 checkAll(Arb.positiveInts(100).map { ("#".repeat(it) + "\n").repeat(it) }) { g ->28 val grid = g.split("\n").dropLast(1)29 t.tobogganTrajectory(grid) shouldBe grid.size30 }31 }32 }33 context("Vertical grid") {34 it("Returns number of trees in the entire grid") {35 checkAll(Arb.list(Arb.stringPattern("[.#]"))) { g ->36 t.tobogganTrajectory(g) shouldBe g.count { l -> l == "#" }37 }38 }39 }40 }41 describe("Toboggan Trajectory 2") {42 context("Sample test") {43 val input: List<String> = File("input.txt").readLines()44 val actual = t.tobogganTrajectory2(input)45 actual shouldBe 265589280046 }47 context("Grid of no trees") {48 it("Returns 0") {49 checkAll(Arb.positiveInts(100).map { (".".repeat(it) + "\n").repeat(it) }) { g ->50 t.tobogganTrajectory2(g.split("\n").dropLast(1)) shouldBe 051 }52 }53 }54 context("Grid of only trees") {55 it("Returns height of grid") {56 checkAll(Arb.positiveInts(100).map { ("#".repeat(it) + "\n").repeat(it) }) { g ->57 val grid = g.split("\n").dropLast(1)58 t.tobogganTrajectory2(grid) shouldBe (Math.pow(grid.size.toDouble(), 4.0) * Math.ceil(grid.size / 2.0)).toLong()59 }60 }61 }62 }63})...

Full Screen

Full Screen

identifierGenerator.kt

Source:identifierGenerator.kt Github

copy

Full Screen

...25import kotlinx.collections.immutable.toPersistentList26internal fun Arb.Companion.semVerIdentifier(minParts: Int = 1, maxParts: Int): Arb<Pair<PersistentList<Identifier>, String>> =27 object : Arb<Pair<PersistentList<Identifier>, String>>() {28 override fun edgecase(rs: RandomSource): Pair<PersistentList<Identifier>, String>? = null29 override fun sample(rs: RandomSource): Sample<Pair<PersistentList<Identifier>, String>> {30 // I don't really know what a sensible maxSize would be, even 100 feels a bit large for a semver identifier31 // the system should be able to handle identifiers of any size (as long as the final string isn't larger32 // than what is supported by the JVM)33 val stringArb = Arb.string(minSize = 1, maxSize = 100, codepoints = Codepoint.semVerIdentifier())34 val sequenceSize = rs.random.nextInt(minParts, maxParts + 1)35 val identifiers = stringArb.samples(rs)36 .take(sequenceSize)37 .map { it.value }38 .map { Identifier.of(it) }39 .toPersistentList()40 val identifierTextSequence = identifiers.joinToString(separator = ".")41 return Sample(identifiers to identifierTextSequence)42 }43 }44internal fun Codepoint.Companion.semVerIdentifier(): Arb<Codepoint> =45 Arb.element((('a'..'z') + ('A'..'Z') + ('0'..'9') + '-').toList()).map { Codepoint(it.code) }...

Full Screen

Full Screen

EvalJvmTest.kt

Source:EvalJvmTest.kt Github

copy

Full Screen

...52 step(0, leaf, mutableListOf())53 }54 val gen = arbitrary { rs ->55 val leaf = { Eval.Now(0) }56 val eval = build(leaf, O.gen.samples().map(Sample<O>::value).take(maxDepth).toList())57 DeepEval(eval)58 }59 }60}...

Full Screen

Full Screen

gen.kt

Source:gen.kt Github

copy

Full Screen

...6 require(1 <= tokenTypes)7 require(1 <= ruleTypes)8 return arbitrary { rs ->9 val names = string(minSize = 1, maxSize = 15)10 .samples(rs)11 .distinct()12 .take(tokenTypes + ruleTypes)13 .mapIndexed { index, it -> index to it.value }14 .toList()15 val tokens = names.takeLast(tokenTypes).map { (index, name) -> TokenType(index, name) }16 val rules = names.take(ruleTypes).map { (index, name) -> RuleType(index, name) }17 NodeTypePool.of(18 grammarName = string(minSize = 1, maxSize = 10).sample(rs).value,19 tokenTypes = tokens,20 ruleTypes = rules21 )22 }23}...

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