Example #1
0
        public void TestAccessArray()
        {
            IKernel kernel = TestModule.GetTestKernel ();
            var factory = kernel.Get<IExecutorFactory>();

            Block statements = new Block ();
            statements.Scope = new Scope ();

            ArrayExpr array = new ArrayExpr(factory.GetArrayExecutor());
            array.Scope = statements.Scope;

            array.Elements.Add(new StringLiteral {
                Value = "yay"
            });

            array.Elements.Add(new StringLiteral {
                Value = "boo"
            });

            Assign assign = new Assign(factory.GetAssignExecutor())
            {
                Ident = new Variable ( factory.GetVariableExecutor ())
                {
                    Scope = statements.Scope,
                    Ident = "x"
                },
                Expr = array,
                Scope = statements.Scope
            };

            Print print = new Print(factory.GetPrintExecutor());
            print.Expr = new Variable( factory.GetVariableExecutor())
            {
                Scope = statements.Scope,
                Ident = "x",
                Indexer = new NumberLiteral()
                {
                    Value = 1
                }
            };

            statements.Add ( assign );
            statements.Add ( print );

            statements.Execute();

            StandardOutDummy output = kernel.Get<IStandardOut> () as StandardOutDummy;
            Assert.AreEqual ( "boo", output.Text );
        }
Example #2
0
 public Executor( Block statements )
 {
     statements.Execute ();
 }