Exemplo n.º 1
0
        public void Compile_ForAllFoundTutorials_Succeeds(
            [ValueSource(nameof(Tutorials))] Tutorial tutorial,
            [ValueSource(nameof(Cultures))] string culture)
        {
            CultureUtilities.WithCulture(culture, () =>
            {
                var grammar = new PegParser().Parse(tutorial.GrammarText);

                var result = PegCompiler.Compile(grammar);

                Assert.That(result.Errors, Is.Empty);
            });
        }
Exemplo n.º 2
0
        public void Parse_For05Calculator_ThrowsForInvalidFormats(
            [Values("5,7+8,9*42")] string expression,
            [ValueSource(nameof(Cultures))] string culture)
        {
            CultureUtilities.WithCulture(culture, () =>
            {
                var tutorial = Tutorial.FindAll().Single(t => t.Name == "05 - Calculator");
                var grammar  = new PegParser().Parse(tutorial.GrammarText);
                var compiled = PegCompiler.Compile(grammar);
                var parser   = CodeCompiler.Compile <object>(compiled);

                Assert.Throws <FormatException>(() => parser.Parse(expression));
            });
        }
Exemplo n.º 3
0
        public void Parse_ForAllFoundTutorials_Succeeds(
            [ValueSource(nameof(Tutorials))] Tutorial tutorial,
            [ValueSource(nameof(Cultures))] string culture)
        {
            CultureUtilities.WithCulture(culture, () =>
            {
                var grammar  = new PegParser().Parse(tutorial.GrammarText);
                var compiled = PegCompiler.Compile(grammar);
                var parser   = CodeCompiler.Compile <object>(compiled);

                var result = parser.Parse(tutorial.TestText);

                Assert.That(result, Is.Not.Null);
            });
        }