Skip to content

Commit

Permalink
release: v4.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ForteScarlet committed Aug 1, 2024
1 parent defde35 commit 470ce89
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 150 deletions.
Empty file added .changelog/v4.4.0.md
Empty file.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# v4.4.0

> Release & Pull Notes: [v4.4.0](https://github.com/simple-robot/simpler-robot/releases/tag/v4.4.0)
- fix(quantcat): 优化统一MergedBinder对null结果、失败结果的处理 ([`d741b8617`](https://github.com/simple-robot/simpler-robot/commit/d741b8617))
- feat(common-streamable): 增加模块与新的公共类型 Streamable, 用来简化部分针对 Sequence 类型的转化操作,例如在JVM中转为 Stream 和在 JS 中转为数组。 ([`1ba898c57`](https://github.com/simple-robot/simpler-robot/commit/1ba898c57))
- fix(quantcat): 优化统一MergedBinder对null结果、失败结果的处理 ([`9c5777847`](https://github.com/simple-robot/simpler-robot/commit/9c5777847))
- feat(common-streamable): 增加模块与新的公共类型 Streamable, 用来简化部分针对 Sequence 类型的转化操作,例如在JVM中转为 Stream 和在 JS 中转为数组。 ([`ca3eaa02b`](https://github.com/simple-robot/simpler-robot/commit/ca3eaa02b))

# v4.3.1

> Release & Pull Notes: [v4.3.1](https://github.com/simple-robot/simpler-robot/releases/tag/v4.3.1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
*
*/

import kotlinx.coroutines.*
import kotlinx.coroutines.test.runTest
import love.forte.simbot.common.atomic.*
import kotlin.test.*

Expand Down Expand Up @@ -133,130 +131,6 @@ class AtomicTests {
}
}

@Test
fun compareAsyncTest() = runTest {
val times = 1000
coroutineScope {
checkAtomicInt(times)
checkAtomicLong(times)
checkAtomicUInt(times)
checkAtomicULong(times)
checkAtomicRef(times)
}
}

private suspend fun checkAtomicInt(times: Int) {
val atomic = atomic(0)

withContext(Dispatchers.Default) {
launch {
repeat(times) {
launch {
atomic += 1
}
yield()
}
}
launch {
repeat(times) {
launch {
atomic.update { it + 1 }
}
yield()
}
}
}

assertEquals(times * 2, atomic.value)
}

private suspend fun checkAtomicLong(times: Int) {
val atomic = atomic(0L)

withContext(Dispatchers.Default) {
launch {
repeat(times) {
launch {
atomic += 1L
}
}
}
launch {
repeat(times) {
launch {
atomic.update { it + 1L }
}
}
}
}

assertEquals((times * 2).toLong(), atomic.value)
}

private suspend fun checkAtomicUInt(times: Int) {
val atomic = atomic(0u)

withContext(Dispatchers.Default) {
launch {
repeat(times) {
launch {
atomic += 1u
}
}
}
launch {
repeat(times) {
launch {
atomic.update { it + 1u }
}
}
}
}

assertEquals((times * 2).toUInt(), atomic.value)
}

private suspend fun checkAtomicULong(times: Int) {
val atomic = atomicUL(0u)

withContext(Dispatchers.Default) {
launch {
repeat(times) {
launch {
atomic += 1u
}
}
}
launch {
repeat(times) {
launch {
atomic.update { it + 1u }
}
}
}
}

assertEquals((times * 2).toULong(), atomic.value)
}

private suspend fun checkAtomicRef(times: Int) {
data class Value(val value: Int)

val atomic = atomicRef(Value(0))

withContext(Dispatchers.Default) {
launch {
repeat(times) {
launch {
atomic.update { it.copy(value = it.value + 1) }
}
}
}
}

assertEquals(Value(times), atomic.value)
}

@Test
fun atomicEqualsTest() {
assertNotEquals(atomic(0), atomic(0))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,32 +30,10 @@ import org.jetbrains.kotlinx.lincheck.strategy.managed.modelchecking.ModelChecki
import org.jetbrains.kotlinx.lincheck.strategy.stress.StressOptions
import kotlin.test.Test

/*
* Copyright (c) 2024. ForteScarlet.
*
* Project https://github.com/simple-robot/simpler-robot
* Email ForteScarlet@163.com
*
* This file is part of the Simple Robot Library (Alias: simple-robot, simbot, etc.).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* Lesser GNU General Public License for more details.
*
* You should have received a copy of the Lesser GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/

abstract class AtomicStressTest {
@Test
fun stressTest() = StressOptions().check(this::class)

@Test
fun modelCheckingTest() = ModelCheckingOptions().check(this::class)
}
Expand Down
2 changes: 1 addition & 1 deletion website
Submodule website updated 1 files
+1 −1 Writerside/v.list

0 comments on commit 470ce89

Please sign in to comment.