bnorm / kotlin-power-assert

Kotlin compiler plugin to enable diagrammed function calls in the Kotlin programming language
Apache License 2.0
581 stars 15 forks source link

show diff for equals assertions. #76

Closed christophsturm closed 5 months ago

christophsturm commented 1 year ago

scalatest and zio test power assert both have this nice feature:

when you write assert("xxx" == "yyy") this is recognized as a comparision and it shows a diff when it fails.

I'm not sure whats the best way to implement that, but maybe it should be implemented not in the compiler plugin but in a support lib, the compiler plugin would just supply the metadata (ast?) to make it possible to find and special case the equals method. (related to #45)

christophsturm commented 1 year ago

also related to #74

christophsturm commented 1 year ago

here's documentation for some of the smart things scalatest does with assert: https://www.scalatest.org/user_guide/using_assertions

bnorm commented 1 year ago

Yes, I do think this is related to #45. One of the benefits we would get from that ticket is the ability to have much more complex diagram logic. Being able to include diffs for equalities of strings and collections, being able to compress the diagram slightly when display strings don't overlap or just have a much more rich diagram, custom behavior specific to individual assertion libraries, etc. There's a lot of benefits and this is something I'd like to tackle next for this library.

For now, I'll leave this ticket up so I remember to add this specific use case, but I suspect it will get implemented alongside #45.

bnorm commented 5 months ago

Ticket has been moved to Kotlin YouTrack: https://youtrack.jetbrains.com/issue/KT-66806