public void EvaluateInvokeExpression()
        {
            InvokeExpression invoke    = new InvokeExpression("foo", new IExpression[] { new ConstantExpression(1) });
            Machine          machine   = new Machine();
            Procedure        procedure = new Procedure("foo", new string[] { "x" }, new ReturnCommand(new NameExpression("x")), machine);

            machine.Environment.SetValue("foo", procedure);

            object result = invoke.Evaluate(machine.Environment);

            Assert.IsNotNull(result);
            Assert.AreEqual(1, result);
        }
Exemple #2
0
        public void EvaluateInvokeExpression()
        {
            ICommand body     = new ReturnCommand(new VariableExpression("x"));
            Function function = new Function(new string[] { "x" }, body);

            BindingEnvironment environment = new BindingEnvironment();

            environment.SetValue("foo", function);

            IExpression expression = new InvokeExpression("foo", new IExpression[] { new ConstantExpression(1) });

            object result = expression.Evaluate(environment);

            Assert.IsNotNull(result);
            Assert.AreEqual(1, result);
        }