Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnmodifiableSequencedSet not supported #3996

Open
ThanksForAllTheFish opened this issue May 3, 2024 · 7 comments
Open

UnmodifiableSequencedSet not supported #3996

ThanksForAllTheFish opened this issue May 3, 2024 · 7 comments

Comments

@ThanksForAllTheFish
Copy link

Which version of Kotest are you using

5.8.1

Related to: #3848

Java Version 21 also introduced unmodifiable wrapper for SequencedSet

When trying to test such a reverse-ordered view with shouldContainExactly it fails with an Assertion Error.

linkedSetOf("a", "b", "c").shouldContainExactly("a", "b", "c") // succeeds
Collections.unmodifiableSequencedSet(linkedSetOf("a", "b", "c")).shouldContainExactly("c", "b", "a") // fails
Collections.unmodifiableCollection(linkedSetOf("a", "b", "c")).shouldContainExactly("c", "b", "a") // succeeds

The issue probably is that the fix for 3848 still checks for subclasses of SequencedSet (https://github.com/kotest/kotest/pull/3873/files#diff-2d15d04b11a0d4ac020e2406ffcaa01ce78d750e0222572a224b7f54e3478309R8), I guess in an attempt to be compatible with older version of Java.

What I saw in other project is to perform different checks for different versions

@mirageoasis
Copy link
Contributor

think there is only two way

  1. gradle 8.2.1 support java 21
  2. upgrade gradle

@mirageoasis
Copy link
Contributor

mirageoasis commented May 4, 2024

think there is only two way

  1. gradle 8.2.1 support java 21
  2. upgrade gradle

oh I found out gradle on kotest main is 8.6.1
for 8.2.1 I think it is impossible to fix but for main version I think I can support java21

@mirageoasis
Copy link
Contributor

mirageoasis commented May 4, 2024

I think I can fix this issue within a week can you give me a time?

think test code will come out within a week

@Kantis
Copy link
Member

Kantis commented May 9, 2024

Won't using Java 21 classes require us to use jvmTarget = 21? Basically meaning that anyone that uses Kotest needs to use Java 21?

@mirageoasis
Copy link
Contributor

Won't using Java 21 classes require us to use jvmTarget = 21? Basically meaning that anyone that uses Kotest needs to use Java 21?

oh... I was not careful enough then is there any other way around? Perhaps different code based on version

@mirageoasis
Copy link
Contributor

@Kantis is there some code I can look around in this repostory? dealing with different java version?

@Kantis
Copy link
Member

Kantis commented Jun 2, 2024

What is the expected in the case of

Collections.unmodifiableSequencedSet(linkedSetOf("a", "b", "c")).shouldContainExactly("c", "b", "a") // fails

Given that linked sets retain order, and shouldContainExactly asserts for order, is it not reasonable that it fails?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants