Host methods act like Javascript functions in many ways. But they do not implement Function prototype so it is not possible to use methods like call and apply on them. What is the recommended way to make them just like Javascript functions?
Here is the expected test case:
public void BugFix_HostMethodCallable()
{
engine.Script.method = new Func<string, int>(x => x.Length);
Assert.AreEqual(2, engine.Evaluate("method('fo')"));
Assert.AreEqual(3, engine.Evaluate("method.call(null, 'foo')"));
Assert.AreEqual(4, engine.Evaluate("method.apply(null, ['foof'])"));
Assert.AreEqual(5, engine.Evaluate("Function.prototype.apply.call(method, null, ['foofo'])"));
Assert.AreEqual(6, engine.Evaluate("Function.prototype.call.apply(method, [null, 'foofoo'])"));
}
Related issue: #195
Reactions are currently unavailable
Host methods act like Javascript functions in many ways. But they do not implement Function prototype so it is not possible to use methods like call and apply on them. What is the recommended way to make them just like Javascript functions?
Here is the expected test case:
Related issue: #195