public void ShouldEvaluateIndexersAsClrFields() { var box = new Box { width = 10, height = 20 }; var jint = new JintEngine() .SetDebugMode(true) .AllowClr() .SetParameter("box", box); Assert.AreEqual(10, jint.Run("return box.width")); Assert.AreEqual(10, jint.Run("return box['width']")); jint.Run("box['height'] = 30;"); Assert.AreEqual(30, box.height); jint.Run("box.height = 18;"); Assert.AreEqual(18, box.height); }
public void ShouldFindOverloadWithNullParam() { var box = new Box { Width = 10, Height = 20 }; var jint = new Jint.JintEngine() .SetDebugMode(true) .SetFunction("assert", new Action<object, object>(Assert.AreEqual)) .SetParameter("box", box); jint.Run(@" assert(1, Number(box.Foo(1))); assert(2, Number(box.Foo(2, null))); "); }
public void ShouldEvaluateIndexersAsClrProperties() { var box = new Box { Width = 10, Height = 20 }; var jint = new JintEngine() .SetDebugMode(true) .SetParameter("box", box); Assert.AreEqual(10, jint.Run("return box.Width")); Assert.AreEqual(10, jint.Run("return box['Width']")); jint.Run("box['Height'] = 30;"); Assert.AreEqual(30, box.Height); jint.Run("box.Height = 18;"); Assert.AreEqual(18, box.Height); }