FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

apply and call should be usable on host methods · Issue #298 · ClearFoundry/ClearScript · GitHub

apply and call should be usable on host methods #298

Description

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


    Back | FazBrowse Home | New Git URL