AjScript.Tests.Interpreter.ParserTests.ParseSimpleNamedFunctionAsCommand C# (CSharp) Method

ParseSimpleNamedFunctionAsCommand() private method

private ParseSimpleNamedFunctionAsCommand ( ) : void
return void
        public void ParseSimpleNamedFunctionAsCommand()
        {
            ICommand command = ParseCommand("function add1(x) { return x+1;}");
            Assert.IsNotNull(command);
            Assert.IsInstanceOfType(command, typeof(ExpressionCommand));

            ExpressionCommand funcmd = (ExpressionCommand)command;
            Assert.IsInstanceOfType(funcmd.Expression, typeof(FunctionExpression));

            FunctionExpression funexpr = (FunctionExpression)funcmd.Expression;

            Assert.IsInstanceOfType(funexpr.Body, typeof(CompositeCommand));
            Assert.AreEqual(1, funexpr.ParameterNames.Length);
            Assert.AreEqual("add1", funexpr.Name);
        }
ParserTests