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

fix: removed diff rendering from the assertion #8808

Open
wants to merge 59 commits into
base: series/2.x
Choose a base branch
from

Conversation

varshith257
Copy link

@varshith257 varshith257 commented May 1, 2024

Changes Made:

  1. Updated the rendering logic to occur outside the assertion function, enabling a more modular architecture for code reuse and alternate renderings.

@CLAassistant
Copy link

CLAassistant commented May 1, 2024

CLA assistant check
All committers have signed the CLA.

Copy link

algora-pbc bot commented May 1, 2024

💵 To receive payouts, sign up on Algora, link your Github account and connect with Stripe/Alipay.

@varshith257
Copy link
Author

@ghostdogpr This PR aims to unify rendering logic to SmartAssertions and ordinary assertions to ensure code reusability. But when the renderdiff is applied to ordinary assertions equalTo function, CI fails with type errors.
Any guidance here?

@varshith257
Copy link
Author

@ghostdogpr This PR aims to unify rendering logic to SmartAssertions and ordinary assertions to ensure code reusability. But when the renderdiff is applied to ordinary assertions equalTo function, CI fails with type errors. Any guidance here?

cc : @kyri-petrou

@varshith257
Copy link
Author

@ghostdogpr This PR aims to unify rendering logic to SmartAssertions and ordinary assertions to ensure code reusability. But when the renderdiff is applied to ordinary assertions equalTo function, CI fails with type errors. Any guidance here?

cc/ @ghostdogpr

Copy link
Member

@ghostdogpr ghostdogpr left a comment

Choose a reason for hiding this comment

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

It doesn't compile because Diff[A] can only compare 2 values of type A but here we are comparing A and B which are different types. The existing code is using diffProduct which infers the objects to be Any so it can compare anything.

@varshith257
Copy link
Author

varshith257 commented May 20, 2024

It doesn't compile because Diff[A] can only compare 2 values of type A but here we are comparing A and B which are different types. The existing code is using diffProduct which infers the objects to be Any so it can compare anything.

It mean can't we unify this diff rendering to both ordinary and smart assertions?

Or

Any typecast is required?

@ghostdogpr
Copy link
Member

Maybe we can change equalTo to return an Assertion[A], that way you can use Diff[A]. I wonder if there are cases where type inference won't work when B is a subtype of A but maybe it's okay to explicitly use type parameters in that case.

@varshith257
Copy link
Author

varshith257 commented May 21, 2024

Maybe we can change equalTo to return an Assertion[A], that way you can use Diff[A]. I wonder if there are cases where type inference won't work when B is a subtype of A but maybe it's okay to explicitly use type parameters in that case.

@ghostdogpr This approach making large no of tests flaky to fail. After my trial and error with this equalTo functions of both SmartAssertions and ordinary, I suscept we can't unify the rendering of diff function.

Waiting for your final review

@ghostdogpr
Copy link
Member

I believe the compile errors are because you changed OptionalImplicit[Diff[A]] to Diff[A]. I don't think this should be changed.

@varshith257
Copy link
Author

@ghostdogpr The changes made to ordinary assertion to unify the same renderdiff of smartAssertions led to fail large chunks of test.

@varshith257
Copy link
Author

@jdegoes @ghostdogpr It's making it hard to use the same render diff logic to both smartAssertions and ordinaryAssertions as they behave differently with their input args. You'll be able to verify through my commits. I have been experimenting with it for a while and it's nearly 60 commits.

Waiting for your guidance to solve/alter approaches

@varshith257 varshith257 marked this pull request as ready for review May 23, 2024 03:19
@varshith257
Copy link
Author

varshith257 commented May 23, 2024

The failing test is of ordinary Assertions changed behavior emitting test fails except lint workflow

@varshith257
Copy link
Author

@ghostdogpr PTAL

@ghostdogpr
Copy link
Member

I don't have anything better to suggest at the moment 😄

@varshith257
Copy link
Author

@varshith257 This does not really fix the problem. It reorganizes the diff rendering code, but does not unify it between smart assertions and ordinary assertions.

I don't have anything better to suggest at the moment 😄

@jdegoes It's for your review now

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

Successfully merging this pull request may close these issues.

zio-test: classic assertion equalTo using Diff
4 participants