Exemple #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.Parser(reader);

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

                Assert.AreEqual(expected, output.ToString());
            }
        }
Exemple #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.Parser(reader);

                parser.Options.AllowVariableShorthand = false;

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

                Assert.AreEqual(expected, output.ToString());
            }
        }
Exemple #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.Parser(reader);

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

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