From 798425e6e8b0f89b374dcda238893f6cb70878f4 Mon Sep 17 00:00:00 2001 From: Karlatemp Date: Sun, 20 Sep 2020 13:55:44 +0800 Subject: [PATCH] Rename SemVersion.RangeRequirement.check to test --- .../console/internal/util/SemVersionInternal.kt | 6 +++--- .../net/mamoe/mirai/console/util/SemVersion.kt | 12 ++++++------ .../net/mamoe/mirai/console/util/TestSemVersion.kt | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/util/SemVersionInternal.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/util/SemVersionInternal.kt index f880a8ecd..718a12d09 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/util/SemVersionInternal.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/util/SemVersionInternal.kt @@ -91,8 +91,8 @@ internal object SemVersionInternal { private fun SemVersion.RangeRequirement.withRule(rule: String): SemVersion.RangeRequirement { return object : SemVersion.RangeRequirement { - override fun check(version: SemVersion): Boolean { - return this@withRule.check(version) + override fun test(version: SemVersion): Boolean { + return this@withRule.test(version) } override fun toString(): String { @@ -112,7 +112,7 @@ internal object SemVersionInternal { if (checks.size == 1) return checks[0] SemVersion.RangeRequirement { checks.forEach { rule -> - if (rule.check(it)) return@RangeRequirement true + if (rule.test(it)) return@RangeRequirement true } return@RangeRequirement false }.withRule(requirement) diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/util/SemVersion.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/util/SemVersion.kt index 783becc0c..713e9dee4 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/util/SemVersion.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/util/SemVersion.kt @@ -62,7 +62,7 @@ public data class SemVersion internal constructor( */ public fun interface RangeRequirement { /** 在 [version] 满足此要求时返回 true */ - public fun check(version: SemVersion): Boolean + public fun test(version: SemVersion): Boolean } public object SemVersionAsStringSerializer : KSerializer by String.serializer().map( @@ -169,25 +169,25 @@ public data class SemVersion internal constructor( return SemVersionInternal.parseRangeRequirement(requirement) } - /** @see [RangeRequirement.check] */ + /** @see [RangeRequirement.test] */ @JvmStatic - public fun RangeRequirement.check(version: String): Boolean = check(parse(version)) + public fun RangeRequirement.test(version: String): Boolean = test(parse(version)) /** * 当满足 [requirement] 时返回 true, 否则返回 false */ @JvmStatic - public fun SemVersion.satisfies(requirement: RangeRequirement): Boolean = requirement.check(this) + public fun SemVersion.satisfies(requirement: RangeRequirement): Boolean = requirement.test(this) /** for Kotlin only */ @JvmStatic @JvmSynthetic - public operator fun RangeRequirement.contains(version: SemVersion): Boolean = check(version) + public operator fun RangeRequirement.contains(version: SemVersion): Boolean = test(version) /** for Kotlin only */ @JvmStatic @JvmSynthetic - public operator fun RangeRequirement.contains(version: String): Boolean = check(version) + public operator fun RangeRequirement.contains(version: String): Boolean = test(version) } @Transient diff --git a/backend/mirai-console/src/test/kotlin/net/mamoe/mirai/console/util/TestSemVersion.kt b/backend/mirai-console/src/test/kotlin/net/mamoe/mirai/console/util/TestSemVersion.kt index 56d34ab71..b76d610e1 100644 --- a/backend/mirai-console/src/test/kotlin/net/mamoe/mirai/console/util/TestSemVersion.kt +++ b/backend/mirai-console/src/test/kotlin/net/mamoe/mirai/console/util/TestSemVersion.kt @@ -14,7 +14,7 @@ package net.mamoe.mirai.console.util -import net.mamoe.mirai.console.util.SemVersion.Companion.check +import net.mamoe.mirai.console.util.SemVersion.Companion.test import org.junit.jupiter.api.Test internal class TestSemVersion { @@ -44,12 +44,12 @@ internal class TestSemVersion { @Test internal fun testRequirement() { fun SemVersion.RangeRequirement.assert(version: String): SemVersion.RangeRequirement { - assert(check(version)) { version } + assert(test(version)) { version } return this } fun SemVersion.RangeRequirement.assertFalse(version: String): SemVersion.RangeRequirement { - assert(!check(version)) { version } + assert(!test(version)) { version } return this } SemVersion.parseRangeRequirement("1.0")