Beispiel #1
0
        public void Can_Have_Block_Inside_Function()
        {
            var syms = new Symbols();

            syms.DefineVariable("a");
            syms.Global.DefineFunction(SymbolTestsHelper.ToFunction("add", 2, new string[] { "a", "b" }, LTypes.Object));

            // func
            var sf = new SymbolsFunction("add", syms.Global);

            syms.Push(sf, true);

            // block in func
            var sb = new SymbolsNested("block", sf);

            syms.Push(sb, true);

            // put variable c in block in function
            syms.DefineVariable("c");

            Assert.IsFalse(syms.Global.Contains("c"));
            Assert.IsFalse(sf.Contains("c"));
            Assert.IsTrue(sb.Contains("c"));
            Assert.IsTrue(syms.Contains("c"));
            Assert.IsTrue(syms.Current.Contains("c"));
        }
Beispiel #2
0
        private ISymbols GetNested()
        {
            var symg = new SymbolsGlobal();

            symg.DefineVariable("a");
            symg.DefineVariable("c");
            symg.DefineFunction(SymbolTestsHelper.ToFunction("add", 2, new string[] { "a", "b" }, LTypes.Object));

            var symn = new SymbolsFunction("add", symg);

            symn.DefineVariable("a");
            symn.DefineVariable("b");
            return(symn);
        }