Hello Patrick,
thanks for your reply. It isn’t exactly what was looking for, however, in your suggestion you brake down the boilerplate code to the minimum. I’ve tried to compile it, but got errors. Here I have a fixed version of your suggestion:
def mkPropEqMatcher[T,V](name:String, extr: T => V)(expVal : V): HavePropertyMatcher[T,V] =
new HavePropertyMatcher[T, V] {
def apply(t: T): HavePropertyMatchResult[V] =
HavePropertyMatchResult(
extr(t) == expVal,
name,
expVal,
extr(t)
)
}
val title = mkPropEqMatcher("title", (_ : Book).title) _
val author = mkPropEqMatcher("author", (_ : Book).author) _
For macro implementation I need to investigate more time. Would I have any advantage comparing to your suggestion?