c.im is one of the many independent Mastodon servers you can use to participate in the fediverse.
C.IM is a general, mainly English-speaking Mastodon instance.

Server stats:

2.8K
active users

G-J van Rooyen

One of the nicest new things I learnt since starting my journey are "expect tests". These are code tests where you don't have to define the expected result beforehand – the test runner figures it out for you!

It's a really nice replacement for that early tinkering with a bit of functionality where you just want to "print it out and see whether it looks right", especially where the output could be a fairly complex data type. OCaml's expect tests make it possible to capture the actual output, and adapt the test's "expectation" accordingly.

Everything uses the output's string representation, so you end up with regression tests that also document your functions' typical output representation very nicely.

To be clear, they're not a replacement for regular unit tests, but they're really useful for figuring out pieces of code where a bit of trial-and-error testing is needed.

Here's an excellent writeup of how they work and why they rock: blog.janestreet.com/the-joy-of

Jane Street Tech BlogWhat if writing tests was a joyful experience?At Jane Street we use a pattern/library called “expect tests” thatmakes test-writing feel like a REPL session, or like exploratoryprogramming in a Jupyter no...