public void TestEvaluation() { object evaluated = mExpressionParser.EvaluateExpression("3.1f", new CodeContext(null)); if ((evaluated is float) == false) { throw new Exception("Values with 'f' should be floats"); } TestEvaluation("-16", -16); TestEvaluation("1+1", 2); TestEvaluation("2.3f - 1", 2.3f - 1); TestEvaluation("1 + (2 * 3.0)", 1 + (2 * 3.0)); TestEvaluation("4/2.0f", 4 / 2.0f); TestEvaluation("true || false", true || false); TestEvaluation("true && false", true && false); // Test full evaluations and verify the results TestEvaluation("System.Math.Max(3, 5)", 5); TestEvaluation("System.Math.Min(8-1, 8)", 7); TestEvaluation("this", mElementRuntime, mElementRuntime); TestEvaluation("this.X", mElementRuntime.X, mElementRuntime); TestEvaluation("this.SomeNewVar", 3.333, mElementRuntime); TestEvaluation("System.Math.Max(this.X, this.Y)", System.Math.Max(mElementRuntime.X, mElementRuntime.Y), mElementRuntime); TestEvaluation("float.PositiveInfinity", float.PositiveInfinity); TestEvaluation("System.Math.Max(float.PositiveInfinity, 0)", float.PositiveInfinity); TestEvaluation("VariableState.Left", mElementRuntime.GetStateRecursively("Left"), mElementRuntime); TestEvaluation("new Vector3()", new Vector3()); TestEvaluation("Color.Red", Color.Red); // need this, but first need to be able to reorder cast properly TestEvaluation("new Color(.3f, .4f, .5f, .6f)", new Color(.3f, .4f, .5f, .6f)); TestEvaluation("\"a\" + \"b\"", "ab", null); TestEvaluation("1 + \"a\" + 2", "1a2", null); TestEvaluation("this.SpriteObject.ScaleX", 3.0f, mElementRuntime); EmitterList emitterList = new EmitterList(); var first = new Emitter(); first.Name = "First"; emitterList.Add(first); var second = new Emitter(); second.Name = "Second"; emitterList.Add(second); TestEvaluation("FindByName(\"First\")", emitterList.FindByName("First"), emitterList); }