示例#1
0
        public void RemebersTheVaraibleValueAfterModificationInSubScope()
        {
            var sut = new GlobalScope(null, "a");

            sut.SetVariable("a", new String("bottom"), false);

            sut.StartScope();
            sut.SetVariable("a", new String("derived"), true);
            var innerAa =
                sut
                .GetVariable("a", new Runtime(new Processors())).Get(new Runtime(new Processors())) as String;

            Assert.Equal("derived", innerAa.Value);
            sut.EndScope();

            var a = sut.GetVariable("a", new Runtime(new Processors())).Get(new Runtime(new Processors())) as String;

            Assert.Equal("bottom", a.Value);
        }
示例#2
0
        public void DoesNotTModifyVariableInUpperFromDerivedScope()
        {
            var sut = new GlobalScope(null, "root");

            sut.SetVariable("a", new String("bottom"), false);

            var derived = sut.DeriveFunctionScope();

            derived.SetVariable("a", new String("derived"), true);
            var innerAa = derived.GetVariable("a", new Runtime(new Processors())).Get(new Runtime(new Processors())) as String;

            Assert.Equal("derived", innerAa.Value);


            var a = sut.GetVariable("a", new Runtime(new Processors())).Get(new Runtime(new Processors())) as String;

            Assert.Equal("bottom", a.Value);
        }
示例#3
0
 public Result GetVariable(string name, IRuntime runtime)
 {
     return(_stack.GetVariable(name, runtime));
 }