public void CreateFunctionsWithEmptyDocString() { DefCommand command = new DefCommand("foo", null, new PassCommand()); Machine machine = new Machine(); command.Execute(machine.Environment); var func = machine.Environment.GetValue("foo"); var dfunc = (DefinedFunction)func; Assert.IsNull(dfunc.GetValue("__doc__")); Assert.IsTrue(dfunc.HasValue("__doc__")); }
public void ExecuteSimpleDefCommand() { IList<ParameterExpression> parameters = new ParameterExpression[] { new ParameterExpression("a", null, false), new ParameterExpression("b", null, false) }; ICommand body = new SetCommand("c", new ConstantExpression(1)); DefCommand command = new DefCommand("foo", parameters, body); Machine machine = new Machine(); command.Execute(machine.Environment); var func = machine.Environment.GetValue("foo"); Assert.IsNotNull(func); Assert.IsInstanceOfType(func, typeof(IFunction)); Assert.IsInstanceOfType(func, typeof(DefinedFunction)); var dfunc = (DefinedFunction)func; Assert.AreEqual(parameters.Count, dfunc.Parameters.Count); Assert.AreEqual(body, dfunc.Body); }
public void ExecuteSimpleDefCommand() { IList <ParameterExpression> parameters = new ParameterExpression[] { new ParameterExpression("a", null, false), new ParameterExpression("b", null, false) }; ICommand body = new SetCommand("c", new ConstantExpression(1)); DefCommand command = new DefCommand("foo", parameters, body); Machine machine = new Machine(); command.Execute(machine.Environment); var func = machine.Environment.GetValue("foo"); Assert.IsNotNull(func); Assert.IsInstanceOfType(func, typeof(IFunction)); Assert.IsInstanceOfType(func, typeof(DefinedFunction)); var dfunc = (DefinedFunction)func; Assert.AreEqual(parameters.Count, dfunc.Parameters.Count); Assert.AreEqual(body, dfunc.Body); }