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

Add support for comparing related types in assertTrue in Scala 2 #8875

Closed

Conversation

andrzejressel
Copy link
Contributor

Fixes #8874

for {
result <- resultZIO
} yield assertTrue(result.is(_.left).contains("type mismatch"))
} @@ scala2Only,
test("comparison compiles when comparing different types") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you mark this one as 'primitive' as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed - after this is merged I can add more tests related to comparing - comparing unrelated classes, comparing related classes etc. - I believe currently behaviour is a bit undefined there.

for {
result <- resultZIO
} yield assertTrue(result.is(_.left).contains("type mismatch"))
} @@ scala2Only,
Copy link
Contributor

@hearnadam hearnadam May 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this not fail with 'type mismatch' on Scala 3?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope:

  - SmartAssertionSpec / equalTo does not compile when comparing unrelated types in Scala 2 - 26 ms
    ? Either was Right
    result.is(_.left).contains("type mismatch")
    result = Right(value = ())
    at D:\MojeProgramy\zio\test-tests\shared\src\test\scala\zio\test\SmartAssertionSpec.scala:227

but it does not work correctly (at least the diffing part): #8754

@jdegoes
Copy link
Member

jdegoes commented Jun 4, 2024

@andrzejressel Would like to get this in. Please re-open when CI is passing! 🙏

@jdegoes jdegoes closed this Jun 4, 2024
@andrzejressel
Copy link
Contributor Author

image

But it passed everything ...

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

Successfully merging this pull request may close these issues.

Scala 2.13 - cannot compare child class to parent class in assertTrue
3 participants