KT-53327 replace Enum.values() with Enum.entries in CharCategory
Also, replace it in stdlib tests where appropriate and disable already unsupported legacy JS tests ^KT-53327 fixed Co-authored-by: Artem Kobzar <Artem.Kobzar@jetbrains.com> Merge-request: KT-MR-10632 Merged-by: Vsevolod Tolstopyatov <qwwdfsad@gmail.com>
This commit is contained in:
committed by
Space Team
parent
c867a4b52f
commit
175cf5e833
@@ -370,8 +370,6 @@ tasks.register("runMocha", NodeTask) {
|
||||
}
|
||||
}
|
||||
|
||||
test.dependsOn runMocha
|
||||
|
||||
tasks.withType(org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile) {
|
||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
@@ -165,8 +165,8 @@ public actual enum class CharCategory(internal val value: Int, public actual val
|
||||
companion object {
|
||||
internal fun valueOf(category: Int): CharCategory =
|
||||
when (category) {
|
||||
in 0..16 -> values()[category]
|
||||
in 18..30 -> values()[category - 1]
|
||||
in 0..16 -> entries[category]
|
||||
in 18..30 -> entries[category - 1]
|
||||
else -> throw IllegalArgumentException("Category #$category is not defined.")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
@@ -169,9 +169,9 @@ public actual enum class CharCategory(public val value: Int, public actual val c
|
||||
*/
|
||||
public fun valueOf(category: Int): CharCategory =
|
||||
when (category) {
|
||||
in 0..16 -> values()[category]
|
||||
in 18..30 -> values()[category - 1]
|
||||
in 0..16 -> entries[category]
|
||||
in 18..30 -> entries[category - 1]
|
||||
else -> throw IllegalArgumentException("Category #$category is not defined.")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
@@ -115,8 +115,9 @@ public enum class CharDirectionality(public val value: Int) {
|
||||
|
||||
|
||||
public companion object {
|
||||
private val directionalityMap by lazy { CharDirectionality.values().associateBy { it.value } }
|
||||
private val directionalityMap by lazy { entries.associateBy { it.value } }
|
||||
|
||||
public fun valueOf(directionality: Int): CharDirectionality = directionalityMap[directionality] ?: throw IllegalArgumentException("Directionality #$directionality is not defined.")
|
||||
public fun valueOf(directionality: Int): CharDirectionality =
|
||||
directionalityMap[directionality] ?: throw IllegalArgumentException("Directionality #$directionality is not defined.")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
@@ -16,7 +16,7 @@ import kotlin.enums.EnumEntries
|
||||
import kotlin.enums.enumEntries
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
@Suppress("UNUSED_EXPRESSION")
|
||||
@Suppress("UNUSED_EXPRESSION", "EnumValuesSoftDeprecate") // <- Used deliberately as a sanity check for tests
|
||||
class EnumEntriesJvmTest {
|
||||
enum class EmptyEnum
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
@@ -12,16 +12,16 @@ import kotlin.time.*
|
||||
class DurationUnitJVMTest {
|
||||
@Test
|
||||
fun conversionFromTimeUnit() {
|
||||
for (unit in DurationUnit.values()) {
|
||||
for (unit in DurationUnit.entries) {
|
||||
val timeUnit = unit.toTimeUnit()
|
||||
assertEquals(unit.name, timeUnit.name)
|
||||
assertEquals(unit, timeUnit.toDurationUnit())
|
||||
}
|
||||
|
||||
for (timeUnit in TimeUnit.values()) {
|
||||
for (timeUnit in TimeUnit.entries) {
|
||||
val unit = timeUnit.toDurationUnit()
|
||||
assertEquals(timeUnit.name, unit.name)
|
||||
assertEquals(timeUnit, unit.toTimeUnit())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,9 +166,9 @@ public actual enum class CharCategory(internal val value: Int, public actual val
|
||||
public companion object {
|
||||
internal fun valueOf(category: Int): CharCategory =
|
||||
when (category) {
|
||||
in 0..16 -> values()[category]
|
||||
in 18..30 -> values()[category - 1]
|
||||
in 0..16 -> entries[category]
|
||||
in 18..30 -> entries[category - 1]
|
||||
else -> throw IllegalArgumentException("Category #$category is not defined.")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import kotlin.text.regex.*
|
||||
private fun Iterable<RegexOption>.toInt(): Int = this.fold(0, { value, option -> value or option.value })
|
||||
|
||||
private fun fromInt(value: Int): Set<RegexOption> =
|
||||
RegexOption.values().filterTo(mutableSetOf<RegexOption>()) { value and it.mask == it.value }
|
||||
RegexOption.entries.filterTo(mutableSetOf<RegexOption>()) { value and it.mask == it.value }
|
||||
|
||||
/**
|
||||
* Provides enumeration values to use to set regular expression options.
|
||||
|
||||
@@ -635,10 +635,10 @@ internal abstract class AbstractCharClass : SpecialToken() {
|
||||
PF("Pf", { CachedCategory(CharCategory.FINAL_QUOTE_PUNCTUATION.value, false) })
|
||||
}
|
||||
|
||||
private val classCache = Array<AtomicReference<CachedCharClass?>>(CharClasses.values().size, {
|
||||
private val classCache = Array<AtomicReference<CachedCharClass?>>(CharClasses.entries.size, {
|
||||
AtomicReference<CachedCharClass?>(null)
|
||||
})
|
||||
private val classCacheMap = CharClasses.values().associate { it -> it.regexName to it }
|
||||
private val classCacheMap = CharClasses.entries.associate { it -> it.regexName to it }
|
||||
|
||||
fun intersects(ch1: Int, ch2: Int): Boolean = ch1 == ch2
|
||||
fun intersects(cc: AbstractCharClass, ch: Int): Boolean = cc.contains(ch)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
||||
@@ -10,6 +10,7 @@ import kotlin.test.*
|
||||
import test.collections.behaviors.listBehavior
|
||||
import test.collections.compare
|
||||
|
||||
@Suppress("EnumValuesSoftDeprecate") // <- Used deliberately as a sanity check for tests
|
||||
class EnumEntriesListTest {
|
||||
|
||||
enum class EmptyEnum
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
@@ -14,10 +14,10 @@ class KTypeProjectionTest {
|
||||
@Test
|
||||
fun constructorArgumentsValidation() {
|
||||
assertFailsWith<IllegalArgumentException> { KTypeProjection(null, typeOf<Int>()) }
|
||||
for (variance in KVariance.values()) {
|
||||
for (variance in KVariance.entries) {
|
||||
assertFailsWith<IllegalArgumentException> { KTypeProjection(variance, null) }.let { e ->
|
||||
assertTrue(variance.toString() in e.message!!)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import kotlin.time.Duration.Companion.minutes
|
||||
import kotlin.time.Duration.Companion.nanoseconds
|
||||
import kotlin.time.Duration.Companion.seconds
|
||||
|
||||
private val units = DurationUnit.values()
|
||||
private val units = DurationUnit.entries
|
||||
|
||||
class DurationTest {
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import kotlin.time.Duration.Companion.nanoseconds
|
||||
import kotlin.time.Duration.Companion.seconds
|
||||
|
||||
class TimeMarkTest {
|
||||
private val units = DurationUnit.values()
|
||||
private val units = DurationUnit.entries
|
||||
|
||||
private fun TimeMark.assertHasPassed(hasPassed: Boolean) {
|
||||
assertEquals(!hasPassed, this.hasNotPassedNow(), "Expected mark in the future")
|
||||
|
||||
Reference in New Issue
Block a user