public void Calculate_BigNumber_OverFlowExcelption(string text)
 {
     var linkedLibraryFactory = new StaticLinkedLibraryFactory(typeof(StandardProcessorBuilder.LinkedMath));
     var processorFactory = new StandardProcessorFactory(linkedLibraryFactory);
     var processor = processorFactory.CreateProcessor();
     processor.Calculate(text);
 }
 public void Calculate_Expression_TargetValue(string text, double value)
 {
     var linkedLibraryFactory = new StaticLinkedLibraryFactory(typeof(StandardProcessorBuilder.LinkedMath));
     var processorFactory = new StandardProcessorFactory(linkedLibraryFactory);
     var processor = processorFactory.CreateProcessor();
     Assert.That(processor.Calculate(text), Is.EqualTo(value).Within(1e-7));
 }
        public void Resolve_UnresolverIdentifier_Throw(string text)
        {
            var lexical = new LexicalAnalyzer(StandardProcessorBuilder.LexicalRules);
            var syntactic = new SyntacticAnalyzer(StandardProcessorBuilder.SyntacticRules);
            var translator = new Translator(StandardProcessorBuilder.TranslateRules);
            var linkedLibraryFactory = new StaticLinkedLibraryFactory(typeof(StandardProcessorBuilder.LinkedMath));
            var linker = new Linker(StandardProcessorBuilder.LinkerRules, linkedLibraryFactory.CreateLinkedLibrary());

            var tokens = lexical.Parse(text);
            var tree = syntactic.Parse(tokens, StandardProcessorBuilder.SyntacticTarget);
            var translatedTree = translator.Translate(tree);
            translator.CheckResult(translatedTree);
            linker.Resolve(translatedTree);

        }
        public void Compile_Expressiion_RightResult(string text, double value)
        {
            var linkedLibraryFactory = new StaticLinkedLibraryFactory(typeof(StandardProcessorBuilder.LinkedMath));

            var lexical = new LexicalAnalyzer(StandardProcessorBuilder.LexicalRules);
            var syntactic = new SyntacticAnalyzer(StandardProcessorBuilder.SyntacticRules);
            var translator = new Translator(StandardProcessorBuilder.TranslateRules);
            var linker = new Linker(StandardProcessorBuilder.LinkerRules, 
                linkedLibraryFactory.CreateLinkedLibrary());
            var tokens = lexical.Parse(text);
            var tree = syntactic.Parse(tokens, StandardProcessorBuilder.SyntacticTarget);
            var translatedTree = translator.Translate(tree);
            translator.CheckResult(translatedTree);
            var linkedTree = linker.Resolve(translatedTree);
            linker.CheckResult(linkedTree);
            var compilator = new Compiler();
            var lambda = compilator.CreateExpression(linkedTree);
            var result = lambda.Compile()();
            Assert.That(result, Is.EqualTo(value).Within(1e-1));
        }
 public void GivenIHaveStandardProcessorWithStandartRules()
 {
     var linkedLibraryFactory = new StaticLinkedLibraryFactory(typeof (StandardProcessorBuilder.LinkedMath));
     var processorFactory = new StandardProcessorFactory(linkedLibraryFactory);
     Processor = processorFactory.CreateProcessor();
 }