public static void Check(Grammars.Grammar grammar) { var grammarName = grammar.Properties.Name; var htmlPath = Path.ChangeExtension(Path.Join(AppContext.BaseDirectory, grammarName), ".html"); Assert.True(File.Exists(htmlPath), $"File '{htmlPath}' does not exist."); var doc = new HtmlDocument(); doc.Load(htmlPath); Assert.Empty(doc.ParseErrors); Assert.All(grammar.Symbols.Nonterminals, x => AssertHasId($"n{x.Index}")); Assert.All(grammar.Productions, x => AssertHasId($"prod{x.Index}")); Assert.All(grammar.LALRStates, x => AssertHasId($"lalr{x.Index}")); Assert.All(grammar.DFAStates, x => AssertHasId($"dfa{x.Index}")); void AssertHasId(string id) => Assert.NotNull(doc.GetElementbyId(id)); }
/// <summary> /// Asserts that two <see cref="Farkle.Grammars.Grammar"/>s have the exact same structure. /// </summary> /// <remarks> /// This is different from the grammar equivalence test in the F# tests. Here, if /// two grammars have two states swapped by each other, the grammars would not be /// considered equivalent. /// </remarks> private static void AssertStrictEquivalence(Grammars.Grammar expected, Grammars.Grammar actual) {