Ejemplo n.º 1
0
        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(reader);

                foreach(var node in parser.ReadNodes()) {
                    output.Append(node.Execute(context));
                }

                Assert.AreEqual(expected, output.ToString());
            }
        }
Ejemplo n.º 2
0
        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(reader);

                parser.Options.AllowVariableShorthand = false;

                foreach(var node in parser.ReadNodes()) {
                    output.Append(node.Execute(context));
                }

                Assert.AreEqual(expected, output.ToString());
            }
        }
Ejemplo n.º 3
0
        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(reader);

                foreach(var node in parser.ReadNodes()) {
                    output.Append(node.Execute(context));
                }

                Assert.AreEqual(expected, output.ToString());
            }
        }