MarkusAmshove / Kluent

Fluent Assertion-Library for Kotlin
https://markusamshove.github.io/Kluent/
MIT License
867 stars 64 forks source link

Add infix forms for backtick functions using auxiliary objects #226

Closed hvpaiva closed 1 year ago

hvpaiva commented 1 year ago

Description

This pull request adds infix forms for some backtick functions that are normally unary relations by using auxiliary objects. The main motivation for this change is to improve readability and fluency when using backtick functions in an infix manner.

Examples:

"   " `should be` Blank
"" `should be` Empty

is more readable and fluent than:

"   ".`should be blank`()
"".`should be empty`()

I have made these changes wherever it was possible to replace the previous unary relation with an object representing it. In some cases, the improvement in readability might be less significant, but using specialized methods, in my opinion, is still preferable to using shouldBeEqualsTo() everywhere.

list `should be` Empty

is more readable and fluent than:

list.`should be empty`()

but not as much as, even I prefer with Empty:

list `should be equals to` emptyList<Int>()

Regarding the implementation:

Concerning the unit tests:

Checklist

Looking forward to your feedback!

Great project! If there's any way I can contribute further or assist with anything, please don't hesitate to let me know. I'm more than happy to collaborate and help out.

MarkusAmshove commented 1 year ago

Hi, thank you for the contribution :-) I find the way you implemented this neat, especially making sure to not break any existing stuff :+1:

The builds currently break, because you're using backtick assertions in files like ShouldBeAFileShould and these methods don't work on Android. Android currently still is in the jvm module, which is fine. To m ake sure the Android build works, there is a bit of magic in the build files which skips files that contain Backtick in the name on Android :-) To fix this, you'll have to take your tests out of the corresponding files and create new test files that have Backtick in their file name

hvpaiva commented 1 year ago

Hi, I have addressed the issue and made the necessary changes. I have moved the tests to new test files with "Backtick" in their file names to ensure compatibility with the Android build. Please let me know if there's anything else I need to do. Thanks! 😄

MarkusAmshove commented 1 year ago

Awesome, thank you for the contribution 🥳 I've merged the changes and will get to releasing them in a new version in the coming days, once I'm back at my machine where I've set up the deployment for maven central :-)

MarkusAmshove commented 1 year ago

Just released 1.73 which includes these changes, should show up in maven central soon :)