예제 #1
0
        public void ValueOfa()
        {
            Tokenizer tokenizer = new Tokenizer();
            using (var stream = CreateResource())
            {
                var tokens = tokenizer.Tokenize(stream);
                var parser = new ExpressionParser();
                var statements = parser.GenerateStatements(tokens).ToList();

                var treeBuilder = new ExpressionDependecyBuilder();
                var expressionTree = treeBuilder.BuildExpressionTree(statements, "a");

                int value = expressionTree.CalcTree();

                Assert.AreEqual(46065, value);
            }
        }
예제 #2
0
        public void ValueOfaWithbOverrided()
        {
            Tokenizer tokenizer = new Tokenizer();
            using (var stream = CreateResource())
            {
                var tokens = tokenizer.Tokenize(stream);
                var parser = new ExpressionParser();
                var statements = parser.GenerateStatements(tokens).ToList();

                var treeBuilder = new ExpressionDependecyBuilder();
                var expressionTree = treeBuilder.BuildExpressionTree(statements, "a");
                Dictionary<string, int> wireValues = new Dictionary<string, int>();
                wireValues.Add("b", 46065);
                int value = expressionTree.CalcTree(wireValues);

                Assert.AreEqual(14134, value);
            }
        }