tialaramex / misfortunate

Perverse implementations of safe Rust traits
9 stars 0 forks source link

Ideas for further incorrect Ord implementations #1

Open Voultapher opened 6 months ago

Voultapher commented 6 months ago

Hi, I've written at length about the various safety aspects a sort implementation can get wrong. One of the things I test for is Ord violation. Over time I've grown a collection of patterns that can stress test code that interacts with comparisons. Looking at the code of misfortunate, it seems only basic all equal, reverse etc. are implemented. In my testing I've found such simple patterns to bypass most of the interesting code, especially the streak and low sample rate ones, managed to reach interesting program states and uncovered tricky bugs.

tialaramex commented 5 months ago

Hi, I should definitely check out your collection. I'm not sure that "stress testing" is particularly a goal for misfortunate, but it would be good to have something more interesting in terms of Ord than what's provided now. I'm going to leave this issue open to remind me to check back into this when I have more time.

tialaramex commented 5 days ago

I added two more sophisticated implementations of Ord, though they're nothing close to the (thank you for your hard work) tests you wrote for the sorts you've worked on.

Misfortunate 1.3.0 now has Echo which gives the ordering of the previous comparison each time, and Jumble which rotates through the three orderings regardless. I may yet dip back in to your work which is pretty inspirational so I'm leaving this Issue open once again, at least for a while.