Episode #7
Parsing dates using proptest and TDD
Testing is hard, as can be seen in the last two episodes. That's why I looked around for better alternatives and found proptest.
Let's take a look at proptest, a library for automatically generating testcases similar to quickcheck (of Haskell fame). We will parse informal english dates like "4th of September 1927" using Proptest and TDD.
▶ Run and edit the code on Gitpod
Keywords
Property testing, Quickcheck, Unit testing, Fuzzy testing, TDD
Things I mentioned during the show
- Proptest crate by Jason Lingle
- Quickcheck crate for Rust by Andrew Gallant
- History of quickcheck
- Chrono english crate by Steve J Donovan
Errata and improvements
It might come as a surprise to you, but every once in a while even I make a mistake. This section covers all improvements made to the code since the episode went live. For an exhaustive list of all changes to the original code, go here. Thanks to all contributors!
Meta
- I prefer to use
ok_or_else
asok_or
evaluates eagerly and might get deprecated
Resources and licenses
- Pizzicato by Setuniman: https://freesound.org/people/Setuniman/sounds/149827/
- Lynx pizzicanto by filmistro: https://filmstro.com/music/pizzicato-strings
- Bug image: https://www.freepik.com/free-vector/funny-insects-icon-set_1488662.htm#term=bug&page=1&position=9
Support!
Preparing, recording, and editing an episode takes a substantial amount of time (around 30 hours total). I do all of this next to my fulltime dayjob. If you want to show your appreciation and help me keep the content free for everybody to enjoy, please consider sponsoring me on Github - no matter the amount. ❤️