Canon/Canon.Tests/LexicalParserTests/DelimiterTests.cs

31 lines
1.1 KiB
C#
Raw Normal View History

2024-03-09 21:44:37 +08:00
using Canon.Core.Enums;
using Canon.Core.LexicalParser;
using Canon.Tests.Utils;
using Canon.Core.Abstractions;
2024-03-09 21:44:37 +08:00
namespace Canon.Tests.LexicalParserTests;
public class DelimiterTests
{
private readonly ILexer _lexer = new Lexer();
2024-03-09 21:44:37 +08:00
[Theory]
[InlineData(",123", DelimiterType.Comma)]
// [InlineData(".123", DelimiterType.Period)]
2024-03-09 21:44:37 +08:00
[InlineData(":123", DelimiterType.Colon)]
[InlineData(";123", DelimiterType.Semicolon)]
[InlineData("(123)", DelimiterType.LeftParenthesis)]
[InlineData(").", DelimiterType.RightParenthesis)]
[InlineData("[asd", DelimiterType.LeftSquareBracket)]
[InlineData("]asd", DelimiterType.RightSquareBracket)]
public void SmokeTest(string input, DelimiterType type)
{
IEnumerable<SemanticToken> tokensEnumerable = _lexer.Tokenize(new StringSourceReader(input));
List<SemanticToken> tokens = tokensEnumerable.ToList();
2024-03-09 21:44:37 +08:00
SemanticToken token = tokens[0];
Assert.Equal(SemanticTokenType.Delimiter, token.TokenType);
DelimiterSemanticToken delimiterSemanticToken = (DelimiterSemanticToken)token;
Assert.Equal(type, delimiterSemanticToken.DelimiterType);
2024-03-09 21:44:37 +08:00
}
}