feat: temporary grammar
This commit is contained in:
34
InkBlot.Tests/LexerTest.cs
Normal file
34
InkBlot.Tests/LexerTest.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
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("<EOF>"),
|
||||
() => divertTokens[3].Type.ShouldBe(InkBlotAntlrGrammarLexer.Eof)
|
||||
);
|
||||
}
|
||||
|
||||
private IList<IToken> 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user