Imagine I have a class like this:
type TFunctionWrapper<T1,T2> = class
private
FFunc : TFunc<T1,T2>;
public
constructor Create(AFunc : TFunc<T1,T2>);
function Apply(AValue : T1) : T2;
end;
with implementation
constructor TFunctionWrapper<T1,T2>.Create(AFunc : TFunc<T1,T2>);
begin
FFunc := AFunc;
end;
function TFunctionWrapper<T1,T2>.Apply(AValue : T1) : T2;
begin
Result := FFunc(AValue);
end;
How can i test, if the assigned functions are the same? Function references cannot be equated with F1 = F2
as it result in a compiler error:
[dcc32 Error] Project1.dpr(37): E2035 Not enough actual parameters
,
which makes pretty good sense.
Anyway, the problem remains: How do you test if assigning a function to a field work as intended, without just testing if the field and the function return the same result on the same input?