public void CheckResult_BlockNode_Throw() { var node = new BlockSyntacticNode( MockRepository.GenerateStub<IBlock>(), Enumerable.Empty<ISyntacticNode>()); var translator = new Translator(Enumerable.Empty<ISyntaxRewriter>()); translator.CheckResult(node); }
public void CheckResult_TermNode_DoesNotThrow() { var node = new TermSyntacticNode( MockRepository.GenerateStub<ITerm>(), Enumerable.Empty<ISyntacticNode>()); var translator = new Translator(Enumerable.Empty<ISyntaxRewriter>()); Assert.DoesNotThrow(() => translator.CheckResult(node)); }
public void TranslateAndCheck_Expressiion_DoesNotThrow(string text) { var lexical = new LexicalAnalyzer(StandardProcessorBuilder.LexicalRules); var syntactic = new SyntacticAnalyzer(StandardProcessorBuilder.SyntacticRules); var translator = new Translator(StandardProcessorBuilder.TranslateRules); Assert.DoesNotThrow( () => { var tokens = lexical.Parse(text); var tree = syntactic.Parse(tokens, StandardProcessorBuilder.SyntacticTarget); var result = translator.Translate(tree); translator.CheckResult(result); }); }
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)); }