Monday, December 13, 2010

scala specs functional matchers

I was reading and wondered if new matchers could be defined more tersely than:

So here it is, with a couple of implicits:

The example shows how to promote a function to a matcher. Currently I didn't find how to define
a function literal with call-by-name semantics, but for simple matchers where a call-by-value semantic is acceptable this trick works fine.


  1. You can have a look at the new ways to create matchers in specs2, they are much easier to create now.