kotest
kotest copied to clipboard
feat: added SequencedSet for isOrderedSet
adding SequencedSet
interface for
isOrderedSet
finally fixing #3848 and fix #3996
working on test code for now
@mirageoasis i kidnapped this PR to try out adding targets for different JDK versions, but it's really hard to get it working correctly and I don't think it's worth the complexity added.
Another thing that I realized is that perhaps we should just rely on reflection in this case. We can add a check like this in isOrderedSet
for JVM:
item::class.java.interfaces.any { it.name == "java.util.SequencedSet" }
and it should be compatible with any java-version and correctly identify subclasses of SequencedSet for newer versions
@Kantis well I finally understood what you have said
actual fun isOrderedSet(item: Iterable<*>) =
item is LinkedHashSet ||
item is SortedSet ||
(item is Set && item.size <= 1) ||
item::class.java.interfaces.any { it.name == "java.util.SequencedSet" }
the real problem is how should run test for jdk21
Is it ok for me implement subclass of EnabledCondition
to run code on specific jdk version?
https://github.com/kotest/kotest/blob/17d1b3b189fe4d804f1d3c6ce14280f724b0f168/kotest-framework/kotest-framework-api/src/jvmMain/kotlin/io/kotest/core/annotation/enabledif/os.kt#L7
like this!