using Antlr4.Runtime; using Shouldly; namespace InkBlot.Tests; public class LexerTest { [Fact] public void TestDivertForLexer() { var divertTokens = GetTokens("<- threadName"); divertTokens.ShouldSatisfyAllConditions( () => divertTokens[0].Text.ShouldBe("<-"), () => divertTokens[0].Type.ShouldBe(InkBlotAntlrGrammarLexer.THREAD_ARROW), () => divertTokens[1].Text.ShouldBe(" "), () => divertTokens[1].Type.ShouldBe(InkBlotAntlrGrammarLexer.WS), () => divertTokens[2].Text.ShouldBe("threadName"), () => divertTokens[2].Type.ShouldBe(InkBlotAntlrGrammarLexer.IDENTIFIER), () => divertTokens[3].Text.ShouldBe(""), () => divertTokens[3].Type.ShouldBe(InkBlotAntlrGrammarLexer.Eof) ); } private IList GetTokens(string text) { var fileReader = new InMemoryFileReader([ ("main.ink", text) ]); var tokensStream = InkBlotParser.GetTokenStream(fileReader, "main.ink"); tokensStream.Fill(); var tokens = tokensStream.GetTokens(); return tokens; } }