Пример #1
0
        public void VariableRedefinitionFail()
        {
            Enviroment enviroment = new Enviroment(TypeInfoProvider.GetGlobal());

            enviroment.StartBlock(CodePosition.GetExternal());
            enviroment.DefineVariable("x", typeof(int), CodePosition.GetExternal());
            enviroment.DefineVariable("x", typeof(int), CodePosition.GetExternal());
            enviroment.EndBlock();
        }
Пример #2
0
        public void VariableTypeSafetyInCode()
        {
            Enviroment enviroment = new Enviroment(TypeInfoProvider.GetGlobal());

            enviroment.StartBlock(CodePosition.GetExternal());
            enviroment.DefineVariable("x", typeof(string), CodePosition.GetExternal());
            TokenParser.Parse("x= 0 .", enviroment, CodePosition.GetExternal());
            enviroment.EndBlock();
        }
Пример #3
0
        public void VariableDefinition()
        {
            Enviroment enviroment = new Enviroment(TypeInfoProvider.GetGlobal());

            enviroment.StartBlock(CodePosition.GetExternal());
            Assert.IsNull(enviroment.GetVariable("y"));
            enviroment.DefineVariable("x", typeof(int), CodePosition.GetExternal());
            Assert.IsNotNull(enviroment.GetVariable("x"));
            enviroment.EndBlock();
        }
Пример #4
0
        public void VariableInheritance()
        {
            Enviroment enviroment = new Enviroment(TypeInfoProvider.GetGlobal());

            enviroment.StartBlock(CodePosition.GetExternal());
            var xOut = enviroment.DefineVariable("x", typeof(string), CodePosition.GetExternal());
            var yOut = enviroment.DefineVariable("y", typeof(int), CodePosition.GetExternal());

            enviroment.StartBlock(CodePosition.GetExternal());
            Assert.AreEqual(yOut, enviroment.GetVariable("y"));
            Assert.AreEqual(xOut, enviroment.GetVariable("x"));
            var yInner = enviroment.DefineVariable("y", typeof(string), CodePosition.GetExternal());
            var zInner = enviroment.DefineVariable("z", typeof(string), CodePosition.GetExternal());

            Assert.AreNotEqual(yOut, enviroment.GetVariable("y"));
            enviroment.EndBlock();
            Assert.AreEqual(yOut, enviroment.GetVariable("y"));
            Assert.IsNull(enviroment.GetVariable("z"));

            enviroment.EndBlock();
        }
Пример #5
0
        public void VariablesInCode()
        {
            Enviroment enviroment = new Enviroment(TypeInfoProvider.GetGlobal());

            enviroment.StartBlock(CodePosition.GetExternal());
            enviroment.DefineVariable("x", typeof(int), CodePosition.GetExternal());
            TokenParser.Parse("DEFINE:y:int . &y . y= 0 . &x . x= &y .", enviroment, CodePosition.GetExternal(), true);

            Assert.IsNotNull(enviroment.GetVariable("y"));
            Assert.AreEqual(enviroment.GetVariable("y").Type, typeof(int));
            enviroment.EndBlock();
        }