public void TestJsEvaluatorPregeneratedCodeDisallowUnsafe() { var eval = new Playground.JSEvaluator.Evaluator(); var result = int.Parse(eval.Eval("2 * 2", false)); Assert.AreEqual(4, result); var result2 = eval.Eval( "var f = function(s){return s + ' (from JS)';}; f('Hello Dolly');", false); Assert.AreEqual("Hello Dolly (from JS)", result2); }
public void TestJsEvaluatorPregeneratedCode() { // http://www.odetocode.com/Code/80.aspx var eval = new Playground.JSEvaluator.Evaluator(); var result = int.Parse(eval.Eval("2 * 2", true)); Assert.AreEqual(4, result); var result2 = eval.Eval( "var f = function(s){return s + ' (from JS)';}; f('Hello Dolly');", true); Assert.AreEqual("Hello Dolly (from JS)", result2); }