public void VariableDefiningTest() { string variableDefinition = "double x = 4"; InstructionsBlock block = new InstructionsBlock(); var declaration = new VariableDeclarationInstruction(variableDefinition, block); declaration.Execute(); Assert.AreEqual(typeof(double), block.localVariables["x"].type); Assert.AreEqual(4.0, block.localVariables["x"].value); }
public void UsingPreDeclaredVarInArythemicStatement() { InstructionsBlock block = new InstructionsBlock(); string variableDefinition = "int x = 4"; var declaration = new VariableDeclarationInstruction(variableDefinition, block); string variableDefinition2 = "int y = 7 + x"; var declaration2 = new VariableDeclarationInstruction(variableDefinition2, block); declaration.Execute(); declaration2.Execute(); Assert.AreEqual(typeof(int), block.localVariables["x"].type); Assert.AreEqual(4.0, block.localVariables["x"].value); Assert.AreEqual(typeof(int), block.localVariables["y"].type); Assert.AreEqual(11.0, block.localVariables["y"].value); }
public ArythmeticStatement(string instructionCode, InstructionsBlock instructionParent) { parent = instructionParent; code = instructionCode; }
public InstructionsBlock(List<string> code, InstructionsBlock parent) { throw new NotImplementedException(); }
/// <summary> /// /// </summary> /// <param name="instructionCode"></param> /// <param name="fooScope">only foo with function scope should be passed here -> in other case expection should be thrown</param> /// <param name="parentScope">this should be next scope to execute or any scope before it (they are passing foos anyway)</param> public FunctionDeclarationInstruction(string instructionCode, InstructionsBlock fooScope, Program parent) { code = instructionCode; functionScope = fooScope; parentScope = parent; }
public VariableDeclarationInstruction(string instructionCode, InstructionsBlock instructionParent) { code = instructionCode; parent = instructionParent; }