Unit Testing a Function Returning a Function

I am confused by this <: character and the return type T => T. It seems this returns a function. I got the function back when the module tested this function. How to check the result?

   def prepend[T <: Message](node: Set[String]): T => T = { out =>
    ...
   out.append("test")
   }
+4
source share
1 answer
T <: Message

The values ​​of T must be of any type that extends Message.

Now the TTBOMK equality / isomorphism functionality is impossible. This means that there is no way to compare a == b, where a: T => T and b: T => T.

You can only generate random inputs and confirm that they give the same result. Not proof of equality, but it could be better than nothing.

If your result val t: T=>T = prepend(...), you can run tas t(some T).

+3

All Articles