-
Notifications
You must be signed in to change notification settings - Fork 90
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
Revive "Strict Equality" for assertEquals()
#521
Commits on Apr 15, 2022
-
Make FailException and ComparisonFailException work more similarly.
Previously, FailException had some custom nice-to-have features that ComparisonFailException didn't have.
Configuration menu - View commit details
-
Copy full SHA for 0a64d8c - Browse repository at this point
Copy the full SHA 0a64d8cView commit details -
Introduce "strict equality" mode for
assertEquals()
and friends.Previously, MUnit had a subtyping constraint on `assertEquals(a, b)` so that it would fail to compile if `a` was not a subtype of `b`. This was a suboptimal solution because the compile error messages could become cryptic in some cases. Additionally, this API didn't integrate with other libaries like Cats that has its own `cats.Eq[A,B]` type-class. Now, MUnit uses a new `munit.Compare[A,B]` type-class for comparing values of different types. By default, MUnit provides a "universal" instance that permits comparison between all types and uses the built-in `==` method. Users can optionally enable "strict equality" by adding the compiler option `"-Xmacro-settings.munit.strictEquality"` in Scala 2. In Scala 3, we use the `Eql[A, B]` type-classes instead to determine type equality.
Configuration menu - View commit details
-
Copy full SHA for 0fa057b - Browse repository at this point
Copy the full SHA 0fa057bView commit details -
Configuration menu - View commit details
-
Copy full SHA for 99e08ba - Browse repository at this point
Copy the full SHA 99e08baView commit details -
Drop strict equality, allow comparison between supertypes/subtypes
This is a fourth attempt at improving strict equality in MUnit `assertEquals()` assertions. * First attempt (current release version): require second argument to be a supertype of the first argument. This has the flaw that the compile error message is cryptic and that the ordering of the arguments affects compilation. * Second attempt: use `Eql[A, B]` in Scala 3 and allow comparing any types in Scala 2. This has the flaw that it's a regression in some cases for Scala 2 users and that `Eql[A, B]` is not really usable in its current form, see related discussion https://contributors.scala-lang.org/t/should-multiversal-equality-provide-default-eql-instances/4574 * Third attempt: implement "strict equality" for Scala 2 with a macro and `Eql[T, T]` in Scala. This improves the situation for Scala 2, but would mean relying on a feature that we can't easily port to Scala 3. * Fourth attempt (this commit): improve the first attempt (current release) by allowing `Compare[A, B]` as long as `A <:< B` OR `B <:< A`. This is possible thanks to an observation by Gabriele Petronella that it's possible to layer the implicits to avoid diverging implicit search. The benefit of the fourth approach is that it works the same way for Scala 3 and Scala 3. It's very nice that we can avoid macros as well.
Configuration menu - View commit details
-
Copy full SHA for ccf1b38 - Browse repository at this point
Copy the full SHA ccf1b38View commit details -
Configuration menu - View commit details
-
Copy full SHA for ebfb185 - Browse repository at this point
Copy the full SHA ebfb185View commit details -
Configuration menu - View commit details
-
Copy full SHA for 93dc160 - Browse repository at this point
Copy the full SHA 93dc160View commit details -
Configuration menu - View commit details
-
Copy full SHA for 506a4aa - Browse repository at this point
Copy the full SHA 506a4aaView commit details -
Fix dotty tests in AssertionsSuite
The Scala 3 (dotty) tests now use compareSubtypeWithSupertype instead of compareSupertypeWithSubtype. Additionally, the "unrelated" test was not seeing the context code above and so I've moved all the code into compileErrors.
Configuration menu - View commit details
-
Copy full SHA for 4b22e56 - Browse repository at this point
Copy the full SHA 4b22e56View commit details -
Configuration menu - View commit details
-
Copy full SHA for 42a6546 - Browse repository at this point
Copy the full SHA 42a6546View commit details -
Configuration menu - View commit details
-
Copy full SHA for 822e5bf - Browse repository at this point
Copy the full SHA 822e5bfView commit details -
Configuration menu - View commit details
-
Copy full SHA for 1503667 - Browse repository at this point
Copy the full SHA 1503667View commit details -
Configuration menu - View commit details
-
Copy full SHA for b28073f - Browse repository at this point
Copy the full SHA b28073fView commit details
Commits on Apr 16, 2022
-
Update Clue deprecation to 1.0
Co-authored-by: Ólafur Páll Geirsson <olafurpg@gmail.com>
Configuration menu - View commit details
-
Copy full SHA for 5a874a0 - Browse repository at this point
Copy the full SHA 5a874a0View commit details -
Fix typo in AssertionsSuite test name
Co-authored-by: Ólafur Páll Geirsson <olafurpg@gmail.com>
Configuration menu - View commit details
-
Copy full SHA for 3c45b9a - Browse repository at this point
Copy the full SHA 3c45b9aView commit details