public void Evaluation() { string input = "x${test - 42}.2"; string expected = "x42.2"; var context = new ExecutionContext(); context.SetVariable("test", 84); var output = new StringBuilder(); using(var reader = new LocatedTextReaderWrapper(input)) { var parser = new Parser.Parser(reader); foreach(var node in parser.ReadNodes()) { output.Append(node.Execute(context)); } Assert.AreEqual(expected, output.ToString()); } }
public void NotVariableShorthand() { string input = "x$test.2"; string expected = "x$test.2"; var context = new ExecutionContext(); var output = new StringBuilder(); using(var reader = new LocatedTextReaderWrapper(input)) { var parser = new Parser.Parser(reader); parser.Options.AllowVariableShorthand = false; foreach(var node in parser.ReadNodes()) { output.Append(node.Execute(context)); } Assert.AreEqual(expected, output.ToString()); } }
private static void CheckParserOutput(string expected, string input) { var context = new ExecutionContext(); var output = new StringBuilder(); using(var reader = new LocatedTextReaderWrapper(input)) { var parser = new Parser.Parser(reader); foreach(var node in parser.ReadNodes()) { output.Append(node.Execute(context)); } Assert.AreEqual(expected, output.ToString()); } }