Best Kotest code snippet using io.kotest.property.exhaustive.Exhaustive.Exhaustive.filterNot
PlayerTest.kt
Source:PlayerTest.kt
1package land.vani.mockpaper.player2import com.destroystokyo.paper.event.player.PlayerPostRespawnEvent3import io.kotest.assertions.fail4import io.kotest.core.spec.style.ShouldSpec5import io.kotest.matchers.collections.shouldContainExactly6import io.kotest.matchers.doubles.shouldNotBeExactly7import io.kotest.matchers.floats.shouldBeExactly8import io.kotest.matchers.ints.shouldBeExactly9import io.kotest.matchers.longs.shouldBeExactly10import io.kotest.matchers.longs.shouldBeGreaterThan11import io.kotest.matchers.longs.shouldNotBeExactly12import io.kotest.matchers.nulls.shouldBeNull13import io.kotest.matchers.nulls.shouldNotBeNull14import io.kotest.matchers.shouldBe15import io.kotest.matchers.types.shouldBeInstanceOf16import io.kotest.property.Exhaustive17import io.kotest.property.checkAll18import io.kotest.property.exhaustive.enum19import io.kotest.property.exhaustive.exhaustive20import io.kotest.property.exhaustive.filterNot21import io.papermc.paper.event.player.AsyncChatEvent22import land.vani.mockpaper.MockPaper23import land.vani.mockpaper.MockPlugin24import land.vani.mockpaper.ServerMock25import land.vani.mockpaper.inventory.EnderChestInventoryMock26import land.vani.mockpaper.inventory.InventoryMock27import land.vani.mockpaper.inventory.InventoryViewMock28import land.vani.mockpaper.randomLocation29import net.kyori.adventure.text.Component30import org.bukkit.BanList31import org.bukkit.GameMode32import org.bukkit.Material33import org.bukkit.command.CommandSender34import org.bukkit.entity.EntityType35import org.bukkit.event.EventHandler36import org.bukkit.event.Listener37import org.bukkit.event.block.BlockBreakEvent38import org.bukkit.event.block.BlockDamageEvent39import org.bukkit.event.block.BlockPlaceEvent40import org.bukkit.event.inventory.InventoryCloseEvent41import org.bukkit.event.inventory.InventoryType42import org.bukkit.event.player.PlayerExpChangeEvent43import org.bukkit.event.player.PlayerLevelChangeEvent44import org.bukkit.event.player.PlayerMoveEvent45import org.bukkit.event.player.PlayerRespawnEvent46import org.bukkit.event.player.PlayerToggleFlightEvent47import org.bukkit.event.player.PlayerToggleSneakEvent48import org.bukkit.event.player.PlayerToggleSprintEvent49import java.util.UUID50@Suppress("DEPRECATION")51class PlayerTest : ShouldSpec({52 lateinit var server: ServerMock53 lateinit var uuid: UUID54 lateinit var player: PlayerMock55 beforeEach {56 server = MockPaper.mock(57 object : ServerMock() {58 private var tick = 059 override val currentServerTime: Long60 get() = super.currentServerTime + tick++61 }62 )63 uuid = UUID.randomUUID()64 player = PlayerMock(server, randomPlayerName(), uuid)65 }66 afterEach {67 MockPaper.unmock()68 }69 should("entityType is Player") {70 player.type shouldBe EntityType.PLAYER71 }72 context("displayName") {73 should("constructor") {74 val name = randomPlayerName()75 player = PlayerMock(server, name, uuid)76 player.displayName() shouldBe Component.text(name)77 }78 should("displayName(Component)") {79 player.displayName(Component.text("some display name"))80 player.displayName() shouldBe Component.text("some display name")81 }82 should("displayName(null)") {83 val name = randomPlayerName()84 player = PlayerMock(server, name, uuid)85 player.displayName(Component.text("some display name"))86 player.displayName(null)87 player.displayName() shouldBe Component.text(name)88 }89 should("getDisplayName") {90 val name = randomPlayerName()91 player = PlayerMock(server, name, uuid)92 player.displayName shouldBe name93 }94 should("setDisplayName") {95 @Suppress("DEPRECATION")96 player.setDisplayName("some display name")97 player.displayName shouldBe "some display name"98 player.displayName() shouldBe Component.text("some display name")99 }100 }101 context("playerList") {102 context("name") {103 should("playerListName is default player.displayName()") {104 player.playerListName() shouldBe player.displayName()105 }106 should("set playerListName") {107 player.playerListName(Component.text("some player list name"))108 player.playerListName() shouldBe Component.text("some player list name")109 }110 }111 context("header") {112 should("playerListHeader is default null") {113 player.playerListHeader().shouldBeNull()114 }115 should("playerListHeader(Component))") {116 player.sendPlayerListHeader(Component.text("some player list header"))117 player.playerListHeader().shouldNotBeNull()118 player.playerListHeader() shouldBe Component.text("some player list header")119 }120 should("setPlayerListHeader(String)") {121 player.playerListHeader = "some player list header"122 player.playerListHeader.shouldNotBeNull()123 player.playerListHeader shouldBe "some player list header"124 player.playerListHeader() shouldBe Component.text("some player list header")125 }126 }127 context("footer") {128 should("playerListFooter is default null") {129 player.playerListFooter().shouldBeNull()130 }131 should("playerListFooter(Component)") {132 player.sendPlayerListFooter(Component.text("some player list footer"))133 player.playerListFooter().shouldNotBeNull()134 player.playerListFooter() shouldBe Component.text("some player list footer")135 }136 should("setPlayerListFooter(String)") {137 player.playerListFooter = "some player list footer"138 player.playerListFooter.shouldNotBeNull()139 player.playerListFooter shouldBe "some player list footer"140 player.playerListFooter() shouldBe Component.text("some player list footer")141 }142 }143 should("sendPlayerListHeaderAndFooter") {144 player.sendPlayerListHeaderAndFooter(145 Component.text("some player list header"),146 Component.text("some player list footer"),147 )148 player.playerListHeader() shouldBe Component.text("some player list header")149 player.playerListFooter() shouldBe Component.text("some player list footer")150 }151 }152 context("compassTarget") {153 should("compassTarget is default player location") {154 player.compassTarget shouldBe player.location155 }156 should("set compassTarget") {157 val location = randomLocation(player.world)158 player.compassTarget = location159 player.compassTarget shouldBe location160 }161 }162 should("respawn") {163 val location = randomLocation(player.world)164 player.setBedSpawnLocation(location, true)165 player.health = 0.0166 player.respawn()167 player.location shouldBe location168 player.health shouldNotBeExactly 0.0169 server.pluginManager.assertEventFired<PlayerRespawnEvent>()170 server.pluginManager.assertEventFired<PlayerPostRespawnEvent>()171 player.location shouldBe location172 }173 should("simulatePlayerMove") {174 val location = randomLocation(player.world)175 val event = player.simulatePlayerMove(location)176 event.isCancelled shouldBe false177 server.pluginManager.assertEventFired<PlayerMoveEvent> { it == event }178 event.to shouldBe location179 }180 context("gameMode") {181 should("gameMode is default survival") {182 player.gameMode shouldBe GameMode.SURVIVAL183 }184 should("set gameMode") {185 player.gameMode = GameMode.CREATIVE186 player.gameMode shouldBe GameMode.CREATIVE187 }188 }189 should("isOnline is default true") {190 player.isOnline shouldBe true191 }192 context("isBanned") {193 should("isBanned is default false") {194 player.isBanned shouldBe false195 }196 should("banned player") {197 server.getBanList(BanList.Type.NAME).addBan(player.name, null, null, null)198 player.isBanned shouldBe true199 }200 }201 context("isWhitelisted") {202 should("isWhitelisted is default false") {203 player.isWhitelisted shouldBe false204 }205 should("whitelist") {206 player.isWhitelisted = true207 player.isWhitelisted shouldBe true208 }209 }210 context("getPlayer") {211 should("getPlayer is default not null") {212 player.player.shouldNotBeNull()213 }214 }215 should("firstPlayed") {216 player = PlayerMock(server, randomPlayerName(), UUID.randomUUID())217 player.hasPlayedBefore() shouldBe false218 player.firstPlayed shouldBeExactly 0219 player.lastPlayed shouldBeExactly 0220 server.addPlayer(player)221 val firstPlayed = player.firstPlayed222 player.hasPlayedBefore() shouldBe true223 firstPlayed shouldBeGreaterThan 0224 firstPlayed shouldBeExactly player.lastPlayed225 // Player reconnects226 server.addPlayer(player)227 player.hasPlayedBefore() shouldBe true228 firstPlayed shouldBeExactly player.firstPlayed229 player.firstPlayed shouldNotBeExactly player.lastPlayed230 }231 context("inventory") {232 should("twice inventory are same") {233 player.inventory shouldBe player.inventory234 }235 should("enderChest") {236 player.enderChest.shouldBeInstanceOf<EnderChestInventoryMock>()237 }238 should("openInventory is default CRAFTING") {239 val view = player.openInventory240 view.shouldNotBeNull()241 view.type shouldBe InventoryType.CRAFTING242 }243 should("openInventory") {244 val inventory = InventoryViewMock(245 player,246 InventoryMock.Crafting,247 InventoryMock(),248 InventoryType.CHEST249 )250 player.openInventory(inventory)251 player.openInventory shouldBe inventory252 }253 should("closeInventory") {254 val inventory = InventoryViewMock(255 player,256 InventoryMock.Crafting,257 InventoryMock(),258 InventoryType.CHEST259 )260 player.openInventory(inventory)261 player.closeInventory()262 player.openInventory.type shouldBe InventoryType.CRAFTING263 server.pluginManager.assertEventFired<InventoryCloseEvent>()264 }265 }266 should("chat") {267 player.chat("some message")268 player.assertSaid("some message")269 player.assertNoMoreSaid()270 @Suppress("DEPRECATION")271 server.pluginManager.assertEventFired<org.bukkit.event.player.PlayerChatEvent>()272 @Suppress("DEPRECATION")273 server.pluginManager.assertEventFired<org.bukkit.event.player.AsyncPlayerChatEvent>()274 server.pluginManager.assertEventFired<AsyncChatEvent>()275 }276 should("perform command") {277 val plugin = server.pluginManager.loadPlugin<MockPlugin>(278 """279 name: MockPlugin280 version: "1.0.0"281 main: ${MockPlugin::class.java.name}282 commands:283 test: {}284 """.trimIndent()285 )286 var executed = false287 var executedSender: CommandSender? = null288 var executedArgs: Array<String>? = null289 plugin.getCommand("test")!!.setExecutor { sender, _, _, args ->290 executed = true291 executedSender = sender292 executedArgs = args293 true294 }295 player.performCommand("test foo bar") shouldBe true296 executed shouldBe true297 executedSender shouldBe player298 executedArgs shouldContainExactly arrayOf("foo", "bar")299 }300 context("sneak") {301 should("player is default not sneaking") {302 player.isSneaking shouldBe false303 }304 should("set sneaking") {305 player.isSneaking = true306 player.isSneaking shouldBe true307 }308 should("eyeHeight") {309 player.isSneaking = true310 player.eyeHeight shouldNotBeExactly player.getEyeHeight(true)311 }312 should("simulateSneak") {313 val event = player.simulateSneaking(true)314 player.isSneaking shouldBe true315 server.pluginManager.assertEventFired<PlayerToggleSneakEvent> {316 it == event317 }318 event.player shouldBe player319 event.isSneaking shouldBe true320 }321 }322 context("sprint") {323 should("player is default not sprinting") {324 player.isSprinting shouldBe false325 }326 should("set sprinting") {327 player.isSprinting = true328 player.isSprinting shouldBe true329 }330 should("simulateSprint") {331 val event = player.simulateSprinting(true)332 player.isSprinting shouldBe true333 server.pluginManager.assertEventFired<PlayerToggleSprintEvent> {334 it == event335 }336 event.player shouldBe player337 event.isSprinting shouldBe true338 }339 }340 context("bedSpawnLocation") {341 should("set bedSpawnLocation") {342 val location = randomLocation(player.world)343 location.block.type = Material.LIGHT_BLUE_BED344 player.bedSpawnLocation.shouldBeNull()345 player.bedSpawnLocation = location346 player.bedSpawnLocation shouldBe location347 player.bedSpawnLocation = null348 player.bedSpawnLocation.shouldBeNull()349 }350 should("set bedSpawnLocation force") {351 val location = randomLocation(player.world)352 player.bedSpawnLocation = location353 player.bedSpawnLocation.shouldBeNull()354 player.setBedSpawnLocation(location, true)355 player.bedSpawnLocation shouldBe location356 }357 }358 context("breakBlock") {359 should("success") {360 val location = randomLocation(player.world)361 location.block.type = Material.DIRT362 player.breakBlock(location.block) shouldBe true363 location.block.type shouldBe Material.AIR364 }365 should("failed") {366 val location = randomLocation(player.world)367 player.gameMode = GameMode.ADVENTURE368 player.breakBlock(location.block) shouldBe false369 }370 }371 context("simulateBlockDamage") {372 should("survival") {373 player.gameMode = GameMode.SURVIVAL374 val location = randomLocation(player.world)375 val event = player.simulateBlocKDamage(location.block)376 event.shouldNotBeNull()377 event.isCancelled shouldBe false378 event.player shouldBe player379 server.pluginManager.assertEventFired<BlockDamageEvent>()380 server.pluginManager.clearEvents()381 }382 should("without survival") {383 checkAll(384 Exhaustive.enum<GameMode>().filterNot { it == GameMode.SURVIVAL }385 ) { gameMode ->386 player.gameMode = gameMode387 val location = randomLocation(player.world)388 player.simulateBlocKDamage(location.block).shouldBeNull()389 }390 }391 should("not insta break") {392 val plugin = server.pluginManager.createMockPlugin()393 player.gameMode = GameMode.SURVIVAL394 var isBroken = false395 server.pluginManager.registerEvents(396 object : Listener {397 @EventHandler398 fun onBlockDamage(event: BlockDamageEvent) {399 event.instaBreak = false400 }401 @EventHandler402 fun onBlockBreak(@Suppress("UNUSED_PARAMETER") event: BlockBreakEvent) {403 isBroken = true404 }405 },406 plugin407 )408 val location = randomLocation(player.world)409 location.block.type = Material.STONE410 val event = player.simulateBlocKDamage(location.block)411 event.shouldNotBeNull()412 event.isCancelled shouldBe false413 isBroken shouldBe false414 location.block.type shouldBe Material.STONE415 }416 should("insta break") {417 val plugin = server.pluginManager.createMockPlugin()418 player.gameMode = GameMode.SURVIVAL419 var brokenCount = 0420 server.pluginManager.registerEvents(421 object : Listener {422 @EventHandler423 fun onBlockDamage(event: BlockDamageEvent) {424 event.instaBreak = true425 }426 @EventHandler427 fun onBlockBreak(@Suppress("UNUSED_PARAMETER") event: BlockBreakEvent) {428 brokenCount++429 }430 },431 plugin432 )433 val location = randomLocation(player.world)434 location.block.type = Material.STONE435 val event = player.simulateBlocKDamage(location.block)436 event.shouldNotBeNull()437 event.isCancelled shouldBe false438 brokenCount shouldBeExactly 1439 location.block.type shouldBe Material.AIR440 }441 }442 context("simulateBlockBreak") {443 should("insta break") {444 val plugin = server.pluginManager.createMockPlugin()445 player.gameMode = GameMode.SURVIVAL446 var brokenCount = 0447 server.pluginManager.registerEvents(448 object : Listener {449 @EventHandler450 fun onBlockDamage(event: BlockDamageEvent) {451 event.instaBreak = true452 }453 @EventHandler454 fun onBlockBreak(@Suppress("UNUSED_PARAMETER") event: BlockBreakEvent) {455 brokenCount++456 }457 },458 plugin459 )460 val location = randomLocation(player.world)461 location.block.type = Material.STONE462 val event = player.simulateBlockBreak(location.block)463 event.shouldNotBeNull()464 event.isCancelled shouldBe false465 brokenCount shouldBeExactly 1466 location.block.type shouldBe Material.AIR467 }468 }469 // TODO: block state is not supported yet.470 xcontext("simulateBlockPlace") {471 should("valid") {472 val location = randomLocation(player.world)473 player.gameMode = GameMode.SURVIVAL474 val event = player.simulateBlockPlace(Material.STONE, location)475 event.shouldNotBeNull()476 event.isCancelled shouldBe false477 server.pluginManager.assertEventFired<BlockPlaceEvent>()478 location.block.type shouldBe Material.STONE479 }480 should("invalid") {481 val location = randomLocation(player.world)482 player.gameMode = GameMode.ADVENTURE483 val event = player.simulateBlockPlace(Material.STONE, location)484 server.pluginManager.assertEventNotFired<BlockPlaceEvent>()485 event.shouldBeNull()486 }487 }488 context("giveExp") {489 val expRequired = intArrayOf(490 7,491 9,492 11,493 13,494 15,495 17,496 19,497 21,498 23,499 25,500 27,501 29,502 31,503 33,504 35,505 37,506 42,507 47,508 52,509 57,510 62,511 67,512 72,513 77,514 82,515 87,516 92,517 97,518 102,519 107,520 112,521 121,522 130,523 139,524 148,525 157,526 166,527 175,528 184,529 193530 )531 should("negative") {532 player.exp = 0.5F533 player.level = 1534 player.giveExpLevels(-100)535 player.exp shouldBeExactly 0.0F536 player.level shouldBeExactly 0537 }538 should("some exp increase level") {539 checkAll(expRequired.withIndex().toList().exhaustive()) { (index, level) ->540 player.exp shouldBeExactly 0.0F541 player.giveExp(level)542 player.level shouldBeExactly index + 1543 }544 }545 should("some exp increase multiple levels") {546 player.giveExp(expRequired[0] + expRequired[1] + expRequired[2])547 player.level shouldBeExactly 3548 player.totalExperience shouldBeExactly expRequired[0] + expRequired[1] + expRequired[2]549 }550 should("some exp decrease level") {551 player.giveExp(expRequired[0] + expRequired[1])552 player.giveExp(-expRequired[1])553 player.level shouldBeExactly 1554 player.totalExperience shouldBeExactly expRequired[0]555 }556 should("some exp decrease multiple levels") {557 player.giveExp(expRequired[0] + expRequired[1])558 player.giveExp(-(expRequired[0] + expRequired[1]))559 player.level shouldBeExactly 0560 player.totalExperience shouldBeExactly 0561 }562 should("level event is fired") {563 val plugin = server.pluginManager.createMockPlugin()564 var levelCount = 0565 server.pluginManager.registerEvents(566 object : Listener {567 @EventHandler568 fun onLevelChanged(@Suppress("UNUSED_PARAMETER") event: PlayerLevelChangeEvent) {569 levelCount++570 }571 @EventHandler572 fun onExpChanged(@Suppress("UNUSED_PARAMETER") event: PlayerExpChangeEvent) {573 fail("PlayerExpChangeEvent should not be called")574 }575 },576 plugin577 )578 player.giveExp(expRequired[0])579 levelCount shouldBeExactly 1580 }581 should("no exp event is fired") {582 val plugin = server.pluginManager.createMockPlugin()583 server.pluginManager.registerEvents(584 object : Listener {585 @EventHandler586 fun onLevelChangeEvent(@Suppress("UNUSED_PARAMETER") event: PlayerLevelChangeEvent) {587 fail("PlayerLevelChangeEvent should not be called")588 }589 @EventHandler590 fun onExpChangeEvent(@Suppress("UNUSED_PARAMETER") event: PlayerExpChangeEvent) {591 fail("PlayerExpChangeEvent should not be called")592 }593 },594 plugin595 )596 player.giveExp(0)597 }598 }599 context("allowFlight") {600 should("allowFlight is default false") {601 player.allowFlight shouldBe false602 }603 should("set allowFlight") {604 player.allowFlight = true605 player.allowFlight shouldBe true606 }607 }608 context("hidePlayer") {609 should("other player default can see") {610 val player2 = server.addPlayer()611 player.canSee(player2) shouldBe true612 }613 @Suppress("DEPRECATION")614 should("deprecated hidePlayer") {615 val player2 = server.addPlayer()616 player.hidePlayer(player2)617 player.canSee(player2) shouldBe false618 player.showPlayer(player2)619 player.canSee(player2) shouldBe true620 }621 should("new hidePlayer") {622 val plugin = server.pluginManager.createMockPlugin()623 val player2 = server.addPlayer()624 player.hidePlayer(plugin, player2)625 player.canSee(player2) shouldBe false626 player.showPlayer(plugin, player2)627 player.canSee(player2) shouldBe true628 }629 @Suppress("DEPRECATION")630 should("old and new") {631 val plugin = server.pluginManager.createMockPlugin()632 val player2 = server.addPlayer()633 player.hidePlayer(plugin, player2)634 player.canSee(player2) shouldBe false635 player.showPlayer(player2)636 player.canSee(player2) shouldBe false637 player.showPlayer(plugin, player2)638 player.canSee(player2) shouldBe true639 }640 @Suppress("DEPRECATION")641 should("eachOther") {642 val plugin1 = server.pluginManager.createMockPlugin("plugin1")643 val plugin2 = server.pluginManager.createMockPlugin("plugin2")644 val player2 = server.addPlayer()645 player.hidePlayer(plugin1, player2)646 player.canSee(player2) shouldBe false647 player.hidePlayer(plugin2, player2)648 player.canSee(player2) shouldBe false649 player.hidePlayer(player2)650 player.canSee(player2) shouldBe false651 player.showPlayer(player2)652 player.canSee(player2) shouldBe false653 player.showPlayer(plugin2, player2)654 player.canSee(player2) shouldBe false655 player.showPlayer(plugin1, player2)656 player.canSee(player2) shouldBe true657 }658 }659 context("flying") {660 should("flying is default false") {661 player.isFlying shouldBe false662 }663 should("set flying") {664 player.isFlying = true665 player.isFlying shouldBe true666 }667 }668 should("simulateToggleFlight") {669 val event = player.simulateToggleFlight(true)670 event.shouldNotBeNull()671 event.isFlying shouldBe true672 player.isFlying shouldBe true673 server.pluginManager.assertEventFired<PlayerToggleFlightEvent>()674 }675 @Suppress("DEPRECATION")676 should("sendTitle") {677 player.sendTitle("some title", "some subtitle")678 player.nextTitle() shouldBe "some title"679 player.nextSubTitle() shouldBe "some subtitle"680 }681 context("saturation") {682 should("saturation is default 5.0") {683 player.saturation shouldBeExactly 5.0F684 }685 should("set saturation") {686 player.foodLevel = 20687 player.saturation = 8.0F688 player.saturation shouldBeExactly 8.0F689 player.foodLevel = 20690 player.saturation = 1000000.0F691 player.saturation shouldBeExactly 20.0F692 }693 }694})...
ShulkerBoxTest.kt
Source:ShulkerBoxTest.kt
1package land.vani.mockpaper.block.state2import io.kotest.assertions.throwables.shouldThrow3import io.kotest.assertions.throwables.shouldThrowUnit4import io.kotest.core.spec.style.ShouldSpec5import io.kotest.matchers.nulls.shouldBeNull6import io.kotest.matchers.shouldBe7import io.kotest.matchers.types.shouldBeInstanceOf8import io.kotest.property.Arb9import io.kotest.property.Exhaustive10import io.kotest.property.arbitrary.enum11import io.kotest.property.arbitrary.filter12import io.kotest.property.checkAll13import io.kotest.property.exhaustive.collection14import land.vani.mockpaper.MockPaper15import land.vani.mockpaper.UnimplementedOperationException16import land.vani.mockpaper.block.BlockMock17import land.vani.mockpaper.inventory.ShulkerBoxInventoryMock18import org.bukkit.DyeColor19import org.bukkit.Material20import org.bukkit.loot.LootTables21import java.util.UUID22private val shulkerBoxes = enumValues<Material>()23 .filter { it.name.endsWith("SHULKER_BOX") }24 .filterNot { it.name.startsWith("LEGACY") }25private fun Exhaustive.Companion.shulkerBox(): Exhaustive<Material> = Exhaustive.collection(shulkerBoxes)26private fun Arb.Companion.notShulkerBox(): Arb<Material> = Arb.enum<Material>()27 .filter { it !in shulkerBoxes }28class ShulkerBoxTest : ShouldSpec({29 lateinit var shulkerBox: ShulkerBoxMock30 beforeEach {31 MockPaper.mock()32 shulkerBox = ShulkerBoxMock(Material.SHULKER_BOX)33 }34 afterEach {35 MockPaper.unmock()36 }37 should("material block state") {38 checkAll(Exhaustive.shulkerBox()) { material ->39 val block = BlockMock(material)40 block.state.shouldBeInstanceOf<ShulkerBoxMock>()41 }42 }43 should("not shulker box cannot create instance") {44 checkAll(Arb.notShulkerBox()) { material ->45 shouldThrow<IllegalArgumentException> {46 ShulkerBoxMock(material)47 }48 }49 }50 should("inventory is ShulkerBoxInventoryMock") {51 shulkerBox.inventory.shouldBeInstanceOf<ShulkerBoxInventoryMock>()52 }53 should("getSnapshot") {54 shulkerBox.getSnapshot().shouldBeInstanceOf<ShulkerBoxMock>()55 }56 should("getLootTable is not implemented yet") {57 shouldThrow<UnimplementedOperationException> {58 shulkerBox.lootTable59 }60 }61 should("setLootTable is not implemented yet") {62 shouldThrowUnit<UnimplementedOperationException> {63 shulkerBox.lootTable = LootTables.SPAWN_BONUS_CHEST.lootTable64 }65 }66 should("getSeed is not implemented yet") {67 shouldThrow<UnimplementedOperationException> {68 shulkerBox.seed69 }70 }71 should("sedSeed is not implemented yet") {72 shouldThrowUnit<UnimplementedOperationException> {73 shulkerBox.seed = 1074 }75 }76 should("isRefillEnabled is not implemented yet") {77 shouldThrow<UnimplementedOperationException> {78 shulkerBox.isRefillEnabled79 }80 }81 should("hasBeenFilled is not implemented yet") {82 shouldThrow<UnimplementedOperationException> {83 shulkerBox.hasBeenFilled()84 }85 }86 should("hasPlayerLooted is not implemented yet") {87 shouldThrow<UnimplementedOperationException> {88 shulkerBox.hasPlayerLooted(UUID.randomUUID())89 }90 }91 should("getLastLooted is not implemented yet") {92 shouldThrow<UnimplementedOperationException> {93 shulkerBox.getLastLooted(UUID.randomUUID())94 }95 }96 should("setHasPlayerLooted is not implemented yet") {97 shouldThrow<UnimplementedOperationException> {98 shulkerBox.setHasPlayerLooted(UUID.randomUUID(), true)99 }100 }101 should("hasPendingRefill is not implemented yet") {102 shouldThrow<UnimplementedOperationException> {103 shulkerBox.hasPendingRefill()104 }105 }106 should("getLastFilled is not implemented yet") {107 shouldThrow<UnimplementedOperationException> {108 shulkerBox.lastFilled109 }110 }111 should("getNextRefill is not implemented yet") {112 shouldThrow<UnimplementedOperationException> {113 shulkerBox.nextRefill114 }115 }116 should("setNextRefill is not implemented yet") {117 shouldThrowUnit<UnimplementedOperationException> {118 shulkerBox.nextRefill = 10119 }120 }121 should("open is not implemented yet") {122 shouldThrow<UnimplementedOperationException> {123 shulkerBox.open()124 }125 }126 should("close is not implemented yet") {127 shouldThrow<UnimplementedOperationException> {128 shulkerBox.close()129 }130 }131 should("isOpen is not implemented yet") {132 shouldThrow<UnimplementedOperationException> {133 shulkerBox.isOpen134 }135 }136 context("getColor") {137 should("getColor is default null") {138 shulkerBox.color.shouldBeNull()139 }140 should("getColor with white shulker box is white") {141 shulkerBox = ShulkerBoxMock(Material.WHITE_SHULKER_BOX)142 shulkerBox.color shouldBe DyeColor.WHITE143 }144 }145})...
BatchMigrationGenerator.kt
Source:BatchMigrationGenerator.kt
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}...
Exhaustive.kt
Source:Exhaustive.kt
1package io.kotest.property.exhaustive2import io.kotest.property.Arb3import io.kotest.property.Exhaustive4import kotlin.jvm.JvmName5/**6 * Returns an [Exhaustive] which provides the values from the given list.7 * @param `as` a non empty list.8 * @return [Exhaustive]9 * @throws [IllegalArgumentException] if the `as` is a empty list.10 */11fun <A> exhaustive(`as`: List<A>): Exhaustive<A> = `as`.exhaustive()12fun <A> Exhaustive.Companion.of(vararg elements: A): Exhaustive<A> = Exhaustive.collection(elements.asList())13/**14 * Returns an [Exhaustive] which provides the values from the receiver.15 * @return [Exhaustive]16 * @throws [IllegalArgumentException] if the receiver is a empty list.17 */18@JvmName("exhaustiveExt")19fun <A> List<A>.exhaustive(): Exhaustive<A> {20 require(this.isNotEmpty()) { "Can't build a Exhaustive for a empty list." }21 return object : Exhaustive<A>() {22 override val values = this@exhaustive23 }24}25/**26 * Returns a new [Exhaustive] which will merge the values from this Exhaustive and the values of27 * the supplied Exhaustive together, taking one from each in turn.28 *29 * In other words, if genA provides 1,2,3 and genB provides 7,8,9 then the merged30 * gen would output 1,7,2,8,3,9.31 *32 * The supplied gen and this gen must have a common supertype.33 *34 * @param other the arg to merge with this one35 * @return the merged arg.36 */37fun <A, B : A, C : A> Exhaustive<B>.merge(other: Exhaustive<C>): Exhaustive<A> = object : Exhaustive<A>() {38 override val values: List<A> = this@merge.values.zip(other.values).flatMap { listOf(it.first, it.second) }39}40/**41 * Returns a new [Exhaustive] which takes its elements from the receiver and filters42 * them using the supplied predicate.43 * In other words this exhaustive is a subset of the elements as determined by the filter.44 */45fun <A> Exhaustive<A>.filter(predicate: (A) -> Boolean) = object : Exhaustive<A>() {46 override val values: List<A> =47 this@filter.values.filter { predicate(it) }48}49/**50 * @return a new [Exhaustive] by filtering this Exhaustives output by the negated function [f]51 */52fun <A> Exhaustive<A>.filterNot(f: (A) -> Boolean): Exhaustive<A> = filter { !f(it) }53/**54 * Returns a new [Exhaustive] which takes its elements from the receiver and maps them using the supplied function.55 */56fun <A, B> Exhaustive<A>.map(f: (A) -> B): Exhaustive<B> = object : Exhaustive<B>() {57 override val values: List<B> =58 this@map.values.map { f(it) }59}60/**61 * Returns a new [Exhaustive] which takes its elements from the receiver and maps them using the supplied function.62 */63fun <A, B> Exhaustive<A>.flatMap(f: (A) -> Exhaustive<B>): Exhaustive<B> = object : Exhaustive<B>() {64 override val values: List<B> =65 this@flatMap.values.flatMap { f(it).values }66}67/**68 * Wraps a [Exhaustive] lazily. The given [f] is only evaluated once,69 * and not until the wrapper [Exhaustive] is evaluated.70 * */71fun <A> Exhaustive.Companion.lazy(f: () -> Exhaustive<A>): Exhaustive<A> {72 return object : Exhaustive<A>() {73 override val values: List<A> by kotlin.lazy { f().values }74 }75}...
ItemGens.kt
Source:ItemGens.kt
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}...
LegendaryItems.kt
Source:LegendaryItems.kt
1package dev.adamko.gildedrose.gildedrosetests2import dev.adamko.gildedrose.testdata.ItemGens3import io.kotest.core.spec.style.BehaviorSpec4import io.kotest.matchers.ints.shouldBeExactly5import io.kotest.property.Arb6import io.kotest.property.arbitrary.filterNot7import io.kotest.property.arbitrary.int8import io.kotest.property.exhaustive.exhaustive9class LegendaryItems : BehaviorSpec({10 // legendary item11 Given("any legendary item") {12 val legendaryItemName = ItemGens.Names.legendary13 val validQualityArb = listOf(80).exhaustive()14 val invalidQualityArb = Arb.int().filterNot { it == 80 }15 listOf(16 "initial quality is valid (80)" to validQualityArb,17 "initial quality is invalid, (is not 80)" to invalidQualityArb,18 ).forEach { (desc, qualityGen) ->19 And(desc) {20 When("quality is updated") {21 Then("quality should be 80") {22 checkAllItems(legendaryItemName, ItemGens.SellIn.any, qualityGen) {23 result.quality shouldBeExactly 8024 }25 }26 // expect "nothing alters"27 xThen("quality is unaffected") {28 // test disabled, as the refactor now means that invalid (not 80) qualities are29 // forced to be 80.30 checkAllItems(legendaryItemName, ItemGens.SellIn.any, qualityGen) {31 result.quality shouldBeExactly inputQuality32 }33 }34 Then("sellIn is unaffected") {35 checkAllItems(legendaryItemName, ItemGens.SellIn.any, qualityGen) {36 result.sellIn shouldBeExactly inputSellIn37 }38 }39 }40 }41 }42 }43})...
Codepoints.kt
Source:Codepoints.kt
1package helpers.generators2import io.kotest.property.Arb3import io.kotest.property.arbitrary.*4import io.kotest.property.exhaustive.exhaustive5private val underscoreReplacerList = listOf(6 '|', '/', '\\', '[', ']', '{', '}', '(', ')', '<', '>'7).map { it.toInt() }8val underscoreReplacers = underscoreReplacerList.exhaustive()9val notUnderscoreReplacers = Arb.codepoints()10 .filterNot { it.value in underscoreReplacerList }11 .map { it.value }12private val charClassMap = listOf(13 '|' to 1,14 '/' to 2, '\\' to 2,15 '[' to 3, ']' to 3,16 '{' to 4, '}' to 4,17 '(' to 5, ')' to 5,18 '<' to 6, '>' to 6,19).map { (key, value) -> key.toInt() to value }20val charClassMembers = charClassMap.exhaustive()21val notCharClassMembers = Arb.codepoints()22 .filterNot { it.value in charClassMap.map { (key, _) -> key } }23 .map { it.value }24private val oppositePairList = listOf(25 '[' to ']',26 ']' to '[',27 '{' to '}',28 '}' to '{',29 '(' to ')',30 ')' to '(',31).map { (key, value) -> key.toInt() to value.toInt() }32val oppositePairs = oppositePairList.exhaustive()33val notOppositePairs = arbitrary { source ->34 val left = Arb.codepoints().sample(source)35 val right = Arb.codepoints().sample(source)36 left.value.value to right.value.value // Ew37}.filterNot { it in oppositePairList }...
Exhaustive.filterNot
Using AI Code Generation
1 fun `filterNot method of Exhaustive class`() {2 val list = listOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)3 val filterList = list.filterNot { it % 2 == 0 }4 println(filterList)5 val exhaustive = Exhaustive.filterNot(Exhaustive.ints(1..10)) { it % 2 == 0 }6 exhaustive.take(100).forEach { println(it) }7 }8 fun `filter method of Exhaustive class`() {9 val list = listOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)10 val filterList = list.filter { it % 2 == 0 }11 println(filterList)12 val exhaustive = Exhaustive.filter(Exhaustive.ints(1..10)) { it % 2 == 0 }13 exhaustive.take(100).forEach { println(it) }14 }15 fun `map method of Exhaustive class`() {16 val list = listOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)17 val filterList = list.map { it * 2 }18 println(filterList)19 val exhaustive = Exhaustive.map(Exhaustive.ints(1..10)) { it * 2 }20 exhaustive.take(100).forEach { println(it) }21 }22 fun `flatMap method of Exhaustive class`() {23 val list = listOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)24 val filterList = list.flatMap { listOf(it, it * 2) }25 println(filterList)26 val exhaustive = Exhaustive.flatMap(Exhaustive.ints(1..10)) { listOf(it, it *
Exhaustive.filterNot
Using AI Code Generation
1val result = Exhaustive.filterNot(Exhaustive.ints(1, 10)) { it % 2 == 0 }2val result = Exhaustive.map(Exhaustive.ints(1, 10)) { it * 2 }3val result = Exhaustive.mapNotNull(Exhaustive.ints(1, 10)) { if (it % 2 == 0) it else null }4val result = Exhaustive.mapIndexed(Exhaustive.ints(1, 10)) { index, value -> index + value }5val result = Exhaustive.mapIndexedNotNull(Exhaustive.ints(1, 10)) { index, value -> if (value % 2 == 0) index + value else null }6val result = Exhaustive.mapNotNullTo(Exhaustive.ints(1, 10), ArrayList()) { if (it % 2 == 0) it else null }7val result = Exhaustive.mapTo(Exhaustive.ints(1, 10), ArrayList()) { it * 2 }8val result = Exhaustive.ints(1, 5) + Exhaustive.ints(5, 10)9val result = Exhaustive.ints(1, 5) + 1010val result = Exhaustive.ints(1, 5).reduce { acc, i -> acc + i }
Exhaustive.filterNot
Using AI Code Generation
1val exhaustive = Exhaustive.filterNot(Exhaustive.ints(0, 10)) { it % 2 == 0 }2exhaustive.values.shouldContainExactly(1, 3, 5, 7, 9)3val exhaustive = Exhaustive.filter(Exhaustive.ints(0, 10)) { it % 2 == 0 }4exhaustive.values.shouldContainExactly(0, 2, 4, 6, 8, 10)5val exhaustive = Exhaustive.map(Exhaustive.ints(0, 10)) { it + 1 }6exhaustive.values.shouldContainExactly(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)7val exhaustive = Exhaustive.mapNotNull(Exhaustive.ints(0, 10)) { if (it % 2 == 0) it else null }8exhaustive.values.shouldContainExactly(0, 2, 4, 6, 8, 10)9val exhaustive = Exhaustive.mapIndexed(Exhaustive.ints(0, 10)) { index, it -> index + it }10exhaustive.values.shouldContainExactly(0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20)11val exhaustive = Exhaustive.mapIndexedNotNull(Exhaustive.ints(0, 10)) { index, it -> if (index % 2 == 0) it else null }12exhaustive.values.shouldContainExactly(0, 2, 4, 6, 8, 10)
Exhaustive.filterNot
Using AI Code Generation
1 val strings = Exhaustive.filterNot(Exhaustive.strings(), { it.contains("a") })2 val ints = Exhaustive.filterNot(Exhaustive.ints(), { it % 2 == 0 })3 val booleans = Exhaustive.filterNot(Exhaustive.booleans(), { it })4 val longs = Exhaustive.filterNot(Exhaustive.longs(), { it % 2 == 0L })5 val bigInts = Exhaustive.filterNot(Exhaustive.bigInts(), { it % 2.toBigInteger() == 0.toBigInteger() })6 val bigDecimals = Exhaustive.filterNot(Exhaustive.bigDecimals(), { it % 2.toBigDecimal() == 0.toBigDecimal() })7 val chars = Exhaustive.filterNot(Exhaustive.chars(), { it in 'a'..'z' })8 val doubles = Exhaustive.filterNot(Exhaustive.doubles(), { it % 2.0 == 0.0 })9 val floats = Exhaustive.filterNot(Exhaustive.floats(), { it % 2.0f == 0.0f })10 val localDates = Exhaustive.filterNot(Exhaustive.localDates(), { it.dayOfMonth % 2 == 0 })11 val localTimes = Exhaustive.filterNot(Exhaustive.localTimes(), { it.second % 2 == 0 })12 val localDateTimes = Exhaustive.filterNot(Exhaustive.localDateTimes(), { it.second % 2 == 0 })13 val instant = Exhaustive.filterNot(Exhaustive.instants(), { it.second % 2 == 0 })14 val zonedDateTimes = Exhaustive.filterNot(Exhaustive.zonedDateTimes(), { it.second % 2 == 0 })15 val durations = Exhaustive.filterNot(Exhaustive.durations(), { it.seconds % 2 == 0 })16 val periods = Exhaustive.filterNot(Exhaustive.periods(), { it.days % 2 == 0 })17 val uuids = Exhaustive.filterNot(Exhaustive.uuids(), { it.toString().contains("a") })18 val enums = Exhaustive.filterNot(Exhaustive.enumValues<Colors>(), { it == Colors.BLUE })19 val lists = Exhaustive.filterNot(Exhaustive.lists(Exhaustive.ints()), { it.size % 2
Exhaustive.filterNot
Using AI Code Generation
1val result = Exhaustive.filterNot { it % 2 == 0 }2println(result)3val result = Exhaustive.map { it * it }4println(result)5val result = Exhaustive.mapNotNull { if (it % 2 == 0) it else null }6println(result)7val result = Exhaustive.mapIndexed { index, element -> index * element }8println(result)9val result = Exhaustive.mapIndexedNotNull { index, element -> if (index % 2 == 0) index * element else null }10println(result)11val result = Exhaustive.flatMap { Exhaustive.of(1..it) }12println(result)13val result = Exhaustive.zip(Exhaustive.of(1..10)) { a, b -> a + b }14println(result)
Exhaustive.filterNot
Using AI Code Generation
1val intNotEven = Exhaustive.filterNot(IntRange(1, 10)) { it % 2 == 0 }2println(intNotEven)3val intEven = Exhaustive.filter(IntRange(1, 10)) { it % 2 == 0 }4println(intEven)5val intEvenSquared = Exhaustive.map(IntRange(1, 10)) { it * it }6println(intEvenSquared)7val intEvenSquared = Exhaustive.flatMap(IntRange(1, 10)) { Exhaustive.of(it, it * it) }8println(intEvenSquared)9val intEvenSquared = Exhaustive.zip(IntRange(1, 10), IntRange(1, 10)) { a, b -> a * b }10println(intEvenSquared)11val intEvenSquared = Exhaustive.zipWithNext(IntRange(1, 10)) { a, b -> a * b }12println(intEvenSquared)
Exhaustive.filterNot
Using AI Code Generation
1 fun `filterNot method of Exhaustive class should return a new Exhaustive instance with filtered values`() {2 val exhaustive = Exhaustive.of(1, 2, 3, 4, 5)3 val predicate = { value: Int -> value % 2 == 0 }4 val filteredExhaustive = exhaustive.filterNot(predicate)5 filteredExhaustive.values should containExactly(1, 3, 5)6 }7}
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!