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(); }
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(); }
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(); }