AjTalk.Tests.Compiler.VmCompilerTests.CompileAndEvaluateInnerBlockWithClosure C# (CSharp) Method

CompileAndEvaluateInnerBlockWithClosure() private method

private CompileAndEvaluateInnerBlockWithClosure ( ) : void
return void
        public void CompileAndEvaluateInnerBlockWithClosure()
        {
            IClass cls = this.CompileClass(
                "Adder",
                new string[] { },
                new string[] { "add: aVector | sum | sum := 0. aVector do: [ :x | sum := sum + x ]. ^sum" });

            Assert.IsNotNull(cls);

            IMethod method = cls.GetInstanceMethod("add:");
            Assert.IsNotNull(method);
            IObject obj = (IObject)cls.NewObject();
            Assert.AreEqual(6, method.Execute(cls.Machine, obj, new object[] { new int[] { 1, 2, 3 } }));
        }