// [TestCase] // FIXME: Cloning functions doesn't work public void CloneFunction() { using (var tc = new TestContext()) { tc.Context.ReportUncaughtExceptions = false; var funRoot = new Rooted <JSFunctionPtr>(tc); Assert.IsTrue(JSAPI.CompileFunction( tc, tc.Global, "test", 0, null, "return global_v;", JSCompileOptions.Default, funRoot )); if (tc.Context.Exception.IsPending) { throw tc.Context.Exception.GetManaged(); } tc.Leave(); using (var tc2 = new TestContext(tc.Runtime)) { var funRoot2 = new Rooted <JSObjectPtr>(tc2); funRoot2.Value = JSAPI.CloneFunctionObject(tc2, funRoot, tc2.Global); if (tc2.Context.Exception.IsPending) { throw tc2.Context.Exception.GetManaged(); } Assert.IsTrue(funRoot2.Value.IsNonzero); tc2.Global["global_v"] = new JS.Value(5); var invokeResult = funRoot2.Value.InvokeFunction(tc2, JSHandleObject.Zero); Assert.AreEqual(5, invokeResult.Value.ToManaged(tc2)); } } }