1. 9

I am writing a simple Lua pattern matching engine (similar to regex’s) in Ocaml and I’m a lazy tester so I wanted to use some quickchecking tool to make my life simpler. Quickchecking this is actually rather difficult though because predicting if the pattern would match or not involves writing the state machine again.

Instead, I decided to do something simpler, I generated two random strings and validated that they didn’t crash the matcher, not whether or not they matched or not. I found a lot of surprising bugs this way and it was really helpful.

I still had to write explicit tests to validate matching worked in the examples I could come up with but I took a way a valuable lesson in that even if I cannot define the property I want, simpler properties can bring a lot of value and confidence to the code as well.

  1.  

  2. 5

    Isn’t this a fuzzer? not a property based checker.

    A agree that using a property based checker against a pattern matching engine would be difficult. Take a look at

    1. 1

      That’s very neat!

      I’ve been looking to start doing some property-based testing for my company’s JS applications. I’ve heard that JSVerify is good, but the docs are a little abstract for someone that hasn’t worked with it before. Anyone have recommendations for some reading to help me get up to speed?