How to use Sequence.forAll method of io.kotest.inspectors.Inspectors class

Best Kotest code snippet using io.kotest.inspectors.Inspectors.Sequence.forAll

InspectorAliasTest.kt

Source:InspectorAliasTest.kt Github

copy

Full Screen

1package com.sksamuel.kotest2import io.kotest.assertions.throwables.shouldThrowAny3import io.kotest.core.spec.style.FunSpec4import io.kotest.inspectors.shouldForAll5import io.kotest.inspectors.shouldForAny6import io.kotest.inspectors.shouldForAtLeast7import io.kotest.inspectors.shouldForAtLeastOne8import io.kotest.inspectors.shouldForAtMost9import io.kotest.inspectors.shouldForAtMostOne10import io.kotest.inspectors.shouldForExactly11import io.kotest.inspectors.shouldForNone12import io.kotest.inspectors.shouldForOne13import io.kotest.inspectors.shouldForSome14import io.kotest.matchers.comparables.shouldBeGreaterThan15import io.kotest.matchers.ints.shouldBeLessThan16import io.kotest.matchers.shouldBe17class InspectorAliasTest : FunSpec({18 val array = arrayOf(1, 2, 3)19 val list = listOf(1, 2, 3)20 val sequence = sequenceOf(1, 2, 3)21 context("forAll") {22 fun block(x: Int) = x shouldBeGreaterThan 023 test("array") {24 array.shouldForAll {25 it shouldBeLessThan 426 }27 shouldThrowAny {28 array.shouldForAll {29 it shouldBeLessThan 330 }31 }32 }33 test("list") {34 list.shouldForAll(::block)35 shouldThrowAny {36 list.shouldForAll {37 it shouldBeLessThan 338 }39 }40 }41 test("sequence") {42 sequence.shouldForAll(::block)43 shouldThrowAny {44 sequence.shouldForAll {45 it shouldBeLessThan 346 }47 }48 }49 }50 context("forOne") {51 fun block(x: Int) = x shouldBe 252 test("array") {53 array.shouldForOne(::block)54 shouldThrowAny {55 array.shouldForOne {56 it shouldBeLessThan 157 }58 }59 }60 test("list") {61 list.shouldForOne(::block)62 shouldThrowAny {63 list.shouldForOne {64 it shouldBeLessThan 165 }66 }67 }68 test("sequence") {69 sequence.shouldForOne(::block)70 shouldThrowAny {71 sequence.shouldForOne {72 it shouldBeLessThan 173 }74 }75 }76 }77 context("forExactly") {78 fun block(x: Int) = x shouldBeGreaterThan 179 val n = 280 test("array") {81 array.shouldForExactly(n, ::block)82 shouldThrowAny {83 array.shouldForExactly(n) {84 it shouldBeLessThan 185 }86 }87 }88 test("list") {89 list.shouldForExactly(n, ::block)90 shouldThrowAny {91 list.shouldForExactly(n) {92 it shouldBeLessThan 193 }94 }95 }96 test("sequence") {97 sequence.shouldForExactly(n, ::block)98 shouldThrowAny {99 sequence.shouldForExactly(n) {100 it shouldBeLessThan 1101 }102 }103 }104 }105 context("forSome") {106 fun block(x: Int) = x shouldBeGreaterThan 2107 test("array") {108 array.shouldForSome(::block)109 shouldThrowAny {110 array.shouldForSome {111 it shouldBeLessThan 1112 }113 }114 }115 test("list") {116 list.shouldForSome(::block)117 shouldThrowAny {118 list.shouldForSome {119 it shouldBeLessThan 1120 }121 }122 }123 test("sequence") {124 sequence.shouldForSome(::block)125 shouldThrowAny {126 sequence.shouldForSome {127 it shouldBeLessThan 1128 }129 }130 }131 }132 context("forAny") {133 fun block(x: Int) = x shouldBeGreaterThan 0134 test("array") {135 array.shouldForAny(::block)136 shouldThrowAny {137 array.shouldForAny {138 it shouldBeLessThan 1139 }140 }141 }142 test("list") {143 list.shouldForAny(::block)144 shouldThrowAny {145 list.shouldForAny {146 it shouldBeLessThan 1147 }148 }149 }150 test("sequence") {151 sequence.shouldForAny(::block)152 shouldThrowAny {153 sequence.shouldForAny {154 it shouldBeLessThan 1155 }156 }157 }158 }159 context("forAtLeast") {160 fun block(x: Int) = x shouldBeGreaterThan 0161 val n = 3162 test("array") {163 array.shouldForAtLeast(n, ::block)164 shouldThrowAny {165 array.shouldForAtLeast(n) {166 it shouldBeLessThan 3167 }168 }169 }170 test("list") {171 list.shouldForAtLeast(n, ::block)172 shouldThrowAny {173 list.shouldForAtLeast(n) {174 it shouldBeLessThan 3175 }176 }177 }178 test("sequence") {179 sequence.shouldForAtLeast(n, ::block)180 shouldThrowAny {181 sequence.shouldForAtLeast(n) {182 it shouldBeLessThan 3183 }184 }185 }186 }187 context("forAtLeastOne") {188 fun block(x: Int) = x shouldBeGreaterThan 0189 test("array") {190 array.shouldForAtLeastOne(::block)191 shouldThrowAny {192 array.shouldForAtLeastOne {193 it shouldBeLessThan 1194 }195 }196 }197 test("list") {198 list.shouldForAtLeastOne(::block)199 shouldThrowAny {200 list.shouldForAtLeastOne {201 it shouldBeLessThan 1202 }203 }204 }205 test("sequence") {206 sequence.shouldForAtLeastOne(::block)207 shouldThrowAny {208 sequence.shouldForAtLeastOne {209 it shouldBeLessThan 1210 }211 }212 }213 }214 context("forAtMost") {215 fun block(x: Int) = x shouldBeGreaterThan 0216 test("array") {217 val arr = arrayOf(0, 0, 1)218 arr.shouldForAtMost(1, ::block)219 shouldThrowAny {220 arr.shouldForAtMost(1) {221 it shouldBeLessThan 3222 }223 }224 }225 test("list") {226 val l = listOf(0, 1, 1)227 l.shouldForAtMost(2, ::block)228 shouldThrowAny {229 l.shouldForAtMost(2) {230 it shouldBeLessThan 3231 }232 }233 }234 test("sequence") {235 sequence.shouldForAtMost(3, ::block)236 shouldThrowAny {237 sequence.shouldForAtMost(2) {238 it shouldBeLessThan 4239 }240 }241 }242 }243 context("forNone") {244 fun block(x: Int) = x shouldBeLessThan 1245 test("array") {246 array.shouldForNone(::block)247 shouldThrowAny {248 array.shouldForNone {249 it shouldBeLessThan 4250 }251 }252 }253 test("list") {254 list.shouldForNone(::block)255 shouldThrowAny {256 list.shouldForNone {257 it shouldBeLessThan 4258 }259 }260 }261 test("sequence") {262 sequence.shouldForNone(::block)263 shouldThrowAny {264 sequence.shouldForNone {265 it shouldBeLessThan 4266 }267 }268 }269 }270 context("forAtMostOne") {271 fun block(x: Int) = x shouldBe 1272 test("array") {273 array.shouldForAtMostOne(::block)274 }275 test("list") {276 list.shouldForAtMostOne(::block)277 }278 test("sequence") {279 sequence.shouldForAtMostOne(::block)280 }281 }282})...

Full Screen

Full Screen

SpdxDeclaredLicenseMappingTest.kt

Source:SpdxDeclaredLicenseMappingTest.kt Github

copy

Full Screen

1/*2 * Copyright (C) 2019 Bosch Software Innovations GmbH3 *4 * Licensed under the Apache License, Version 2.0 (the "License");5 * you may not use this file except in compliance with the License.6 * You may obtain a copy of the License at7 *8 * https://www.apache.org/licenses/LICENSE-2.09 *10 * Unless required by applicable law or agreed to in writing, software11 * distributed under the License is distributed on an "AS IS" BASIS,12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13 * See the License for the specific language governing permissions and14 * limitations under the License.15 *16 * SPDX-License-Identifier: Apache-2.017 * License-Filename: LICENSE18 */19package org.ossreviewtoolkit.utils.spdx20import io.kotest.core.spec.style.WordSpec21import io.kotest.inspectors.forAll22import io.kotest.matchers.collections.beEmpty23import io.kotest.matchers.ints.shouldBeGreaterThanOrEqual24import io.kotest.matchers.nulls.beNull25import io.kotest.matchers.should26import io.kotest.matchers.shouldBe27import io.kotest.matchers.string.containADigit28import io.kotest.matchers.string.shouldContain29import org.ossreviewtoolkit.utils.common.titlecase30class SpdxDeclaredLicenseMappingTest : WordSpec({31 "The list" should {32 "not contain any duplicate keys with respect to capitalization" {33 val keys = SpdxDeclaredLicenseMapping.rawMapping.keys.toMutableList()34 val uniqueKeys = SpdxDeclaredLicenseMapping.mapping.keys35 // Remove keys one by one as calling "-" would remove all occurrences of a key.36 uniqueKeys.forEach { uniqueKey -> keys.remove(uniqueKey) }37 keys should beEmpty()38 }39 "not contain any deprecated values" {40 SpdxDeclaredLicenseMapping.rawMapping.values.forAll {41 it.isValid(SpdxExpression.Strictness.ALLOW_CURRENT) shouldBe true42 }43 }44 "not associate licenses without a version to *-only" {45 val keysWithImpliedVersion = listOf(46 // See http://www.gwtproject.org/terms.html#licenses which explicitly mentions "GNU Lesser General47 // Public License v. 2.1".48 "GWT Terms",49 "http://www.gwtproject.org/terms.html",50 // This forwards to http://www.gnu.org/licenses/lgpl-3.0.html which has a version in the URL.51 "http://www.gnu.org/copyleft/lesser.html"52 )53 SpdxDeclaredLicenseMapping.rawMapping.asSequence().forAll { (key, license) ->54 if (key !in keysWithImpliedVersion && license.licenses().any { it.endsWith("-only") }) {55 key should containADigit()56 }57 }58 }59 }60 "The mapping" should {61 "not contain single ID strings" {62 val licenseIdMapping = SpdxDeclaredLicenseMapping.mapping.filter { (_, expression) ->63 expression is SpdxLicenseIdExpression64 }65 licenseIdMapping.keys.forAll { declaredLicense ->66 @Suppress("SwallowedException")67 try {68 val tokens = getTokensByTypeForExpression(declaredLicense)69 tokens.size shouldBeGreaterThanOrEqual 270 if (tokens.size == 2) {71 // Rule out that the 2 tokens are caused by IDSTRING and PLUS.72 declaredLicense shouldContain " "73 }74 } catch (e: SpdxException) {75 // For untokenizable strings no further checks are needed.76 }77 }78 }79 "not contain plain SPDX license ids" {80 SpdxDeclaredLicenseMapping.mapping.keys.forAll { declaredLicense ->81 SpdxLicense.forId(declaredLicense) should beNull()82 }83 }84 "be case-insensitive" {85 SpdxDeclaredLicenseMapping.mapping.asSequence().forAll { (key, license) ->86 SpdxDeclaredLicenseMapping.map(key.lowercase()) shouldBe license87 SpdxDeclaredLicenseMapping.map(key.uppercase()) shouldBe license88 SpdxDeclaredLicenseMapping.map(key.titlecase()) shouldBe license89 }90 }91 }92})...

Full Screen

Full Screen

SpdxSimpleLicenseMappingTest.kt

Source:SpdxSimpleLicenseMappingTest.kt Github

copy

Full Screen

1/*2 * Copyright (C) 2019 Bosch Software Innovations GmbH3 *4 * Licensed under the Apache License, Version 2.0 (the "License");5 * you may not use this file except in compliance with the License.6 * You may obtain a copy of the License at7 *8 * https://www.apache.org/licenses/LICENSE-2.09 *10 * Unless required by applicable law or agreed to in writing, software11 * distributed under the License is distributed on an "AS IS" BASIS,12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13 * See the License for the specific language governing permissions and14 * limitations under the License.15 *16 * SPDX-License-Identifier: Apache-2.017 * License-Filename: LICENSE18 */19package org.ossreviewtoolkit.utils.spdx20import io.kotest.core.spec.style.WordSpec21import io.kotest.inspectors.forAll22import io.kotest.matchers.collections.beEmpty23import io.kotest.matchers.collections.shouldHaveAtLeastSize24import io.kotest.matchers.collections.shouldHaveAtMostSize25import io.kotest.matchers.nulls.beNull26import io.kotest.matchers.should27import io.kotest.matchers.shouldBe28import io.kotest.matchers.string.containADigit29import org.ossreviewtoolkit.utils.common.titlecase30class SpdxSimpleLicenseMappingTest : WordSpec({31 "The raw map" should {32 "not contain any duplicate keys with respect to capitalization" {33 val keys = SpdxSimpleLicenseMapping.customLicenseIdsMap.keys.toMutableList()34 val uniqueKeys = SpdxSimpleLicenseMapping.customLicenseIds.keys35 // Remove keys one by one as calling "-" would remove all occurrences of a key.36 uniqueKeys.forEach { uniqueKey -> keys.remove(uniqueKey) }37 keys should beEmpty()38 }39 "not contain any deprecated values" {40 SpdxSimpleLicenseMapping.customLicenseIdsMap.values.forAll {41 it.deprecated shouldBe false42 }43 }44 "not associate licenses without a version to *-only" {45 SpdxSimpleLicenseMapping.customLicenseIdsMap.asSequence().forAll { (key, license) ->46 if (license.id.endsWith("-only")) key should containADigit()47 }48 }49 }50 "The mapping" should {51 "contain only single ID strings" {52 SpdxSimpleLicenseMapping.mapping.keys.forAll { declaredLicense ->53 val tokens = getTokensByTypeForExpression(declaredLicense)54 val types = tokens.map { (type, _) -> type }55 tokens shouldHaveAtLeastSize 156 tokens shouldHaveAtMostSize 257 tokens.joinToString("") { (_, text) -> text } shouldBe declaredLicense58 types.first() shouldBe SpdxExpressionLexer.IDSTRING59 types.getOrElse(1) { SpdxExpressionLexer.PLUS } shouldBe SpdxExpressionLexer.PLUS60 }61 }62 "not contain plain SPDX license ids" {63 SpdxSimpleLicenseMapping.customLicenseIds.keys.forAll { declaredLicense ->64 SpdxLicense.forId(declaredLicense) should beNull()65 }66 }67 "be case-insensitive" {68 SpdxSimpleLicenseMapping.customLicenseIds.asSequence().forAll { (key, license) ->69 SpdxSimpleLicenseMapping.map(key.lowercase(), mapDeprecated = false) shouldBe license70 SpdxSimpleLicenseMapping.map(key.uppercase(), mapDeprecated = false) shouldBe license71 SpdxSimpleLicenseMapping.map(key.titlecase(), mapDeprecated = false) shouldBe license72 SpdxSimpleLicenseMapping.map(key.lowercase(), mapDeprecated = true) shouldBe license73 SpdxSimpleLicenseMapping.map(key.uppercase(), mapDeprecated = true) shouldBe license74 SpdxSimpleLicenseMapping.map(key.titlecase(), mapDeprecated = true) shouldBe license75 }76 }77 }78})...

Full Screen

Full Screen

Inspectors.kt

Source:Inspectors.kt Github

copy

Full Screen

1package com.github.shwaka.kotest.inspectors2import io.kotest.inspectors.ElementPass3import io.kotest.inspectors.runTests4fun <T> Sequence<T>.forAll(fn: (T) -> Unit) = toList().forAll(fn)5fun <T> Array<T>.forAll(fn: (T) -> Unit) = asList().forAll(fn)6fun <T> Collection<T>.forAll(fn: (T) -> Unit) {7 val results = runTests(this, fn)8 val passed = results.filterIsInstance<ElementPass<T>>()9 if (passed.size < this.size) {10 val msg = "${passed.size} elements passed but expected ${this.size}"11 buildAssertionError(msg, results)12 }13}14fun <T> Sequence<T>.forOne(fn: (T) -> Unit) = toList().forOne(fn)15fun <T> Array<T>.forOne(fn: (T) -> Unit) = asList().forOne(fn)16fun <T> Collection<T>.forOne(fn: (T) -> Unit) = forExactly(1, fn)17fun <T> Sequence<T>.forExactly(k: Int, fn: (T) -> Unit) = toList().forExactly(k, fn)18fun <T> Array<T>.forExactly(k: Int, fn: (T) -> Unit) = toList().forExactly(k, fn)19fun <T> Collection<T>.forExactly(k: Int, fn: (T) -> Unit) {20 val results = runTests(this, fn)21 val passed = results.filterIsInstance<ElementPass<T>>()22 if (passed.size != k) {23 val msg = "${passed.size} elements passed but expected $k"24 buildAssertionError(msg, results)25 }26}27fun <T> Sequence<T>.forSome(fn: (T) -> Unit) = toList().forSome(fn)28fun <T> Array<T>.forSome(fn: (T) -> Unit) = toList().forSome(fn)29fun <T> Collection<T>.forSome(fn: (T) -> Unit) {30 val results = runTests(this, fn)31 val passed = results.filterIsInstance<ElementPass<T>>()32 if (passed.isEmpty()) {33 buildAssertionError("No elements passed but expected at least one", results)34 } else if (passed.size == size) {35 buildAssertionError("All elements passed but expected < $size", results)36 }37}38fun <T> Sequence<T>.forAny(fn: (T) -> Unit) = toList().forAny(fn)39fun <T> Array<T>.forAny(fn: (T) -> Unit) = toList().forAny(fn)40fun <T> Collection<T>.forAny(fn: (T) -> Unit) = forAtLeastOne(fn)41fun <T> Sequence<T>.forAtLeastOne(fn: (T) -> Unit) = toList().forAtLeastOne(fn)42fun <T> Array<T>.forAtLeastOne(fn: (T) -> Unit) = toList().forAtLeastOne(fn)43fun <T> Collection<T>.forAtLeastOne(f: (T) -> Unit) = forAtLeast(1, f)44fun <T> Sequence<T>.forAtLeast(k: Int, fn: (T) -> Unit) = toList().forAtLeast(k, fn)45fun <T> Array<T>.forAtLeast(k: Int, fn: (T) -> Unit) = toList().forAtLeast(k, fn)46fun <T> Collection<T>.forAtLeast(k: Int, fn: (T) -> Unit) {47 val results = runTests(this, fn)48 val passed = results.filterIsInstance<ElementPass<T>>()49 if (passed.size < k) {50 val msg = "${passed.size} elements passed but expected at least $k"51 buildAssertionError(msg, results)52 }53}54fun <T> Sequence<T>.forAtMostOne(fn: (T) -> Unit) = toList().forAtMostOne(fn)55fun <T> Array<T>.forAtMostOne(fn: (T) -> Unit) = toList().forAtMostOne(fn)56fun <T> Collection<T>.forAtMostOne(fn: (T) -> Unit) = forAtMost(1, fn)57fun <T> Sequence<T>.forAtMost(k: Int, fn: (T) -> Unit) = toList().forAtMost(k, fn)58fun <T> Array<T>.forAtMost(k: Int, fn: (T) -> Unit) = toList().forAtMost(k, fn)59fun <T> Collection<T>.forAtMost(k: Int, fn: (T) -> Unit) {60 val results = runTests(this, fn)61 val passed = results.filterIsInstance<ElementPass<T>>()62 if (passed.size > k) {63 val msg = "${passed.size} elements passed but expected at most $k"64 buildAssertionError(msg, results)65 }66}67fun <T> Sequence<T>.forNone(fn: (T) -> Unit) = toList().forNone(fn)68fun <T> Array<T>.forNone(fn: (T) -> Unit) = toList().forNone(fn)69fun <T> Collection<T>.forNone(f: (T) -> Unit) {70 val results = runTests(this, f)71 val passed = results.filterIsInstance<ElementPass<T>>()72 if (passed.isNotEmpty()) {73 val msg = "${passed.size} elements passed but expected ${0}"74 buildAssertionError(msg, results)75 }76}...

Full Screen

Full Screen

LangTest.kt

Source:LangTest.kt Github

copy

Full Screen

1package com.github.durun.nitron.test2import com.github.durun.nitron.core.config.AntlrParserConfig3import com.github.durun.nitron.core.config.LangConfig4import com.github.durun.nitron.core.config.loader.NitronConfigLoader5import com.github.durun.nitron.core.parser.antlr.ParserStore6import io.kotest.assertions.throwables.shouldNotThrowAny7import io.kotest.core.spec.style.FreeSpec8import io.kotest.core.spec.style.freeSpec9import io.kotest.inspectors.forAll10import io.kotest.matchers.collections.shouldBeIn11import io.kotest.matchers.collections.shouldContainAll12import io.kotest.matchers.collections.shouldHaveAtLeastSize13import io.kotest.matchers.paths.shouldBeReadable14import io.kotest.mpp.log15import java.nio.file.Path16import java.nio.file.Paths17import kotlin.io.path.toPath18class LangTest : FreeSpec({19 val configPath = Paths.get("config/nitron.json")20 NitronConfigLoader.load(configPath).langConfig21 .filter { (_, config) -> config.parserConfig is AntlrParserConfig }22 .forEach { (lang, config) -> include(langTestFactory(lang, config)) }23})24fun langTestFactory(lang: String, config: LangConfig) = freeSpec {25 "config for $lang (${config.fileName})" - {26 val parser = ParserStore.getOrNull(config.parserConfig)27 val parserConfig = config.parserConfig as AntlrParserConfig28 "grammar files exist" {29 val files = parserConfig.grammarFilePaths + parserConfig.utilJavaFilePaths30 log { "${config.fileName}: files=$files" }31 files shouldHaveAtLeastSize 132 files.forAll {33 it.shouldBeReadable()34 }35 }36 "defines parser settings" {37 shouldNotThrowAny {38 ParserStore.getOrThrow(config.parserConfig)39 }40 }41 "defines start rule" {42 val startRule = parserConfig.startRule43 log { "${config.fileName}: startRule=$startRule" }44 startRule shouldBeIn parser!!.antlrParser.ruleNames45 }46 "defines at least 1 extension of sourcecode" {47 val extensions = config.extensions48 log { "${config.fileName}: extensions=$extensions" }49 extensions shouldHaveAtLeastSize 150 }51 "uses correct rule/token name" {52 val usedRules: List<String> = (53 config.processConfig.normalizeConfig.ignoreRules +54 config.processConfig.normalizeConfig.mapping.keys +55 config.processConfig.normalizeConfig.indexedMapping.keys +56 config.processConfig.splitConfig.splitRules57 )58 .flatMap { it.split('/').filter(String::isNotEmpty) }59 .filterNot { it.contains(Regex("[^a-zA-Z]")) }60 val antlrParser = parser!!.antlrParser61 val allowedRules = antlrParser.ruleNames + antlrParser.tokenTypeMap.keys62 runCatching {63 allowedRules shouldContainAll usedRules64 }.onFailure {65 println("see: ${parserConfig.grammarFilePaths.map(Path::normalize)}")66 val errorSymbols = (usedRules - allowedRules)67 config.fileUri.toURL().readText().lineSequence().forEachIndexed { index, line ->68 val file = config.fileUri.toPath()69 val lineNo = index + 170 errorSymbols.filter { line.contains(it) }.forEach {71 println("""$file:$lineNo: "$it" is not defined""")72 }73 }74 }.getOrThrow()75 }76 }77}...

Full Screen

Full Screen

InputBufferTests.kt

Source:InputBufferTests.kt Github

copy

Full Screen

1package com.github.mpe85.grampa.input2import com.ibm.icu.impl.StringSegment3import io.kotest.assertions.throwables.shouldThrow4import io.kotest.core.spec.style.StringSpec5import io.kotest.inspectors.forAll6import io.kotest.matchers.shouldBe7class InputBufferTests : StringSpec({8 val buffers = listOf(9 StringBufferInputBuffer(StringBuffer("foobar")),10 StringBuilderInputBuffer(StringBuilder("foobar")),11 StringSegmentInputBuffer(StringSegment("foobar", false)),12 StringInputBuffer("foobar")13 )14 "Get character" {15 buffers.forAll { buffer ->16 buffer.getChar(0) shouldBe 'f'17 buffer.getChar(1) shouldBe 'o'18 buffer.getChar(2) shouldBe 'o'19 buffer.getChar(3) shouldBe 'b'20 buffer.getChar(4) shouldBe 'a'21 buffer.getChar(5) shouldBe 'r'22 shouldThrow<IndexOutOfBoundsException> {23 buffer.getChar(-1)24 }25 shouldThrow<IndexOutOfBoundsException> {26 buffer.getChar(6)27 }28 }29 }30 "Get code point" {31 buffers.forAll { buffer ->32 buffer.getCodePoint(0) shouldBe 'f'.code33 buffer.getCodePoint(1) shouldBe 'o'.code34 buffer.getCodePoint(2) shouldBe 'o'.code35 buffer.getCodePoint(3) shouldBe 'b'.code36 buffer.getCodePoint(4) shouldBe 'a'.code37 buffer.getCodePoint(5) shouldBe 'r'.code38 shouldThrow<IndexOutOfBoundsException> {39 buffer.getCodePoint(-1)40 }41 shouldThrow<IndexOutOfBoundsException> {42 buffer.getCodePoint(6)43 }44 }45 }46 "Get length" {47 buffers.forAll { buffer ->48 buffer.length shouldBe 649 }50 }51 "Sub sequence" {52 buffers.forAll { buffer ->53 buffer.subSequence(0, 6) shouldBe "foobar"54 buffer.subSequence(0, 1) shouldBe "f"55 buffer.subSequence(1, 3) shouldBe "oo"56 buffer.subSequence(5, 5) shouldBe ""57 shouldThrow<IndexOutOfBoundsException> {58 buffer.subSequence(-2, 1)59 }60 shouldThrow<IndexOutOfBoundsException> {61 buffer.subSequence(0, 7)62 }63 shouldThrow<IndexOutOfBoundsException> {64 buffer.subSequence(5, 3)65 }66 }67 }68 "Get position" {69 buffers.forAll { buffer ->70 (0..5).forEach { idx ->71 buffer.getPosition(idx).apply {72 line shouldBe 173 column shouldBe idx + 174 }75 }76 shouldThrow<IndexOutOfBoundsException> {77 buffer.getPosition(-1)78 }79 shouldThrow<IndexOutOfBoundsException> {80 buffer.getPosition(6)81 }82 }83 }84})...

Full Screen

Full Screen

CompilerTest.kt

Source:CompilerTest.kt Github

copy

Full Screen

1package ru.tesserakt.kodept.core2import io.kotest.assertions.arrow.core.shouldBeRight3import io.kotest.core.spec.style.DescribeSpec4import io.kotest.inspectors.forAll5import io.kotest.matchers.sequences.shouldContainAll6import io.kotest.matchers.sequences.shouldHaveSize7class CompilerTest : DescribeSpec({8 describe("compiler") {9 it("should builds") {10 val compilationContext = CompilationContext {11 loader = MemoryLoader.singleSnippet("module Test =>")12 }13 compilationContext flow {14 val source = readSources().bind()15 val tokens = source.tokenize().bind()16 val parse = tokens.parse().then { abstract() }.bind()17 source.source shouldHaveSize 118 tokens.tokens shouldHaveSize 119 tokens.tokens.first().value shouldHaveSize 520 parse.ast shouldHaveSize 121 parse.ast.forAll { it.value.toEither().shouldBeRight() }22 }23 }24 it("should parse files") {25 val compilationContext =26 CompilationContext {27 loader = MemoryLoader.fromText("module A => struct B", "module B =>")28 }29 compilationContext flow {30 val source = readSources().bind()31 val tokens = source.tokenize().bind()32 val parse = tokens.parse().then { abstract() }.bind()33 source.source shouldHaveSize 234 tokens.tokens shouldHaveSize 235 tokens.tokens.map { it.value.count() } shouldContainAll sequenceOf(9, 5)36 parse.ast shouldHaveSize 237 parse.ast.forAll { it.value.toEither().shouldBeRight() }38 }39 }40 }41})...

Full Screen

Full Screen

SequenceEqTest.kt

Source:SequenceEqTest.kt Github

copy

Full Screen

1package com.sksamuel.kotest.eq2import io.kotest.assertions.assertSoftly3import io.kotest.assertions.eq.SequenceEq4import io.kotest.core.spec.style.FunSpec5import io.kotest.inspectors.forAll6import io.kotest.matchers.nulls.shouldBeNull7import io.kotest.matchers.nulls.shouldNotBeNull8import io.kotest.matchers.shouldBe9import io.kotest.matchers.shouldNotBe10import java.nio.file.Paths11import java.util.concurrent.ConcurrentLinkedQueue12import kotlin.time.Duration.Companion.seconds13class SequenceEqTest : FunSpec({14 test("built-in sequence equality is reflexive but not symmetric") {15 val seq1 = sequenceOf(1, 2, 3)16 // reflexive17 seq1.equals(seq1) shouldBe true18 (seq1.hashCode() == seq1.hashCode()) shouldBe true19 // symmetric20 val seq2 = sequenceOf(1, 2, 3)21 seq1.equals(seq2) shouldBe /* true, but is */ false22 (seq1.hashCode() == seq2.hashCode()) shouldBe /* true, but is */ false23 seq2.equals(seq1) shouldBe /* true, but is */ false24 (seq2.hashCode() == seq1.hashCode()) shouldBe /* true, but is */ false25 }26 // therefore...27 test("Sequence type is not supported") {28 val error = SequenceEq.equals(sequenceOf(1, 2, 3), sequenceOf(2, 3))29 assertSoftly {30 error.shouldNotBeNull()31 error.message?.startsWith("Sequence type is not supported") shouldBe true32 }33 }34})...

Full Screen

Full Screen

Sequence.forAll

Using AI Code Generation

copy

Full Screen

1val list = listOf(1, 2, 3, 4, 5, 6, 7)2Sequence.forAll(list) { it % 2 == 0 } shouldBe false3Sequence.forAll(list) { it % 2 == 1 } shouldBe true4Sequence.forAll(list) { it > 0 } shouldBe true5Sequence.forAll(list) { it < 0 } shouldBe false6Sequence.forAll(list) { it < 10 } shouldBe true7Sequence.forAll(list) { it > 10 } shouldBe false8val list = listOf(1, 2, 3, 4, 5, 6, 7)9Sequence.forNone(list) { it % 2 == 0 } shouldBe false10Sequence.forNone(list) { it % 2 == 1 } shouldBe false11Sequence.forNone(list) { it > 0 } shouldBe false12Sequence.forNone(list) { it < 0 } shouldBe true13Sequence.forNone(list) { it < 10 } shouldBe false14Sequence.forNone(list) { it > 10 } shouldBe true15val list = listOf(1, 2, 3, 4, 5, 6, 7)16Sequence.forOne(list) { it % 2 == 0 } shouldBe true17Sequence.forOne(list) { it % 2 == 1 } shouldBe false18Sequence.forOne(list) { it > 0 } shouldBe true19Sequence.forOne(list) { it < 0 } shouldBe false20Sequence.forOne(list) { it < 10 } shouldBe true21Sequence.forOne(list) { it > 10 } shouldBe false22val list = listOf(1, 2, 3, 4, 5, 6, 7)23Sequence.forExactly(1, list) { it % 2 == 0 } shouldBe true24Sequence.forExactly(1, list) { it % 2 == 1 } shouldBe false25Sequence.forExactly(1, list) { it > 0 } shouldBe true26Sequence.forExactly(1, list) { it <

Full Screen

Full Screen

Sequence.forAll

Using AI Code Generation

copy

Full Screen

1val list = listOf(1, 2, 3, 4)2list.forAll { it < 5 } shouldBe true3list.forAll { it > 5 } shouldBe false4val list = listOf(1, 2, 3, 4)5val list = listOf(1, 2, 3, 4)6val list = listOf(1, 2, 3, 4)7val list = listOf(1, 2, 3, 4)8val list = listOf(1, 2, 3, 4)9val list1 = listOf(1, 2, 3, 4)10val list2 = listOf(1, 2, 3, 4)11list1.shouldContainSame(listOf(1, 2, 4,

Full Screen

Full Screen

Sequence.forAll

Using AI Code Generation

copy

Full Screen

1val sequence = sequenceOf(1, 2, 3, 4, 5)2forAll(sequence) { it > 0 } shouldBe true3forAll(sequence) { it > 1 } shouldBe false4val sequence = sequenceOf(1, 2, 3, 4, 5)5forNone(sequence) { it > 5 } shouldBe true6forNone(sequence) { it > 1 } shouldBe false7val sequence = sequenceOf(1, 2, 3, 4, 5)8forAtLeastOne(sequence) { it > 1 } shouldBe true9forAtLeastOne(sequence) { it > 5 } shouldBe false10val sequence = sequenceOf(1, 2, 3, 4, 5)11forAtLeast(3, sequence) { it > 1 } shouldBe true12forAtLeast(3, sequence) { it > 4 } shouldBe false13forAtLeast(10, sequence) { it > 1 } shouldBe false14val sequence = sequenceOf(1, 2, 3, 4, 5)15forAtMostOne(sequence) { it > 1 } shouldBe false16forAtMostOne(sequence) { it > 5 } shouldBe true17val sequence = sequenceOf(1, 2, 3, 4, 5)18forAtMost(3, sequence) { it > 1 } shouldBe false19forAtMost(3, sequence) { it > 4 } shouldBe true20forAtMost(10, sequence) { it > 1 } shouldBe true21val sequence = sequenceOf(1, 2, 3, 4, 5)22forExactlyOne(sequence) { it > 1 } shouldBe false

Full Screen

Full Screen

Sequence.forAll

Using AI Code Generation

copy

Full Screen

1class InspectorsTest {2 fun `test forAll`() {3 val list = listOf(2,4,6,8,10)4 list.forAll {5 }6 }7}8class InspectorsTest {9 fun `test forNone`() {10 val list = listOf(2,4,6,8,10)11 list.forNone {12 }13 }14}15class InspectorsTest {16 fun `test forAtLeast`() {17 val list = listOf(2,4,6,8,10)18 list.forAtLeast(2) {19 }20 }21}22class InspectorsTest {23 fun `test forAtMost`() {24 val list = listOf(2,4,6,8,10)25 list.forAtMost(2) {26 }27 }28}29class InspectorsTest {30 fun `test forExactly`() {31 val list = listOf(2,4,6,8,10)32 list.forExactly(2) {33 }34 }35}36class InspectorsTest {37 fun `test forOne`() {38 val list = listOf(2,4,6,8,10)

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.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful