public void AccessVariableAfterInit() { var context = new Context(); var interpretatorRegion = new RegionInterpretator(context); var expressionString = "int a = 0;" + "a = 54-33;" + "real b = 0;" + "b = 154.26/4.12+15*a-151;" + "bool c = false;" + "c = (b >= 4) && (a == 21) && (\"Apple\" == \"Apple\");" + "string pinkie = \"\";" + "pinkie = \"Pinkie Pie\";" + "string s = pinkie + \" is coolest pony\";"; interpretatorRegion.Run(expressionString); Assert.AreEqual(54 - 33, (int)context.Lookup("a").Value); Assert.AreEqual(154.26 / 4.12 + 15 * (54 - 33) - 151, (double)context.Lookup("b").Value); Assert.AreEqual((154.26 / 4.12 + 15 * (54 - 33) - 151 >= 4) && (54 - 33 == 21) && ("Apple" == "Apple"), (bool)context.Lookup("c").Value); Assert.AreEqual("Pinkie Pie is coolest pony", (string)context.Lookup("s").Value); }
public void MultiInitVariableTest() { var context = new Context(); var interpretatorRegion = new RegionInterpretator(context); var expressionString = "int a = 54-33;" + "real b = 154.26/4.12+15*(15.12*45.87)-151;" + "bool c = (5 >= 4) && (5*4 != 21) && (\"Apple\" == \"Apple\");"+ "string s = \"Pinkie Pie\" + \" is coolest pony\";"; interpretatorRegion.Run(expressionString); Assert.AreEqual(54 - 33, (int)context.Lookup("a").Value); Assert.AreEqual(154.26 / 4.12 + 15 * (15.12 * 45.87) - 151, (double)context.Lookup("b").Value); Assert.AreEqual((5 >= 4) && (5 * 4 != 21) && ("Apple" == "Apple"), (bool)context.Lookup("c").Value); Assert.AreEqual("Pinkie Pie is coolest pony", (string)context.Lookup("s").Value); }