2024-03-09 21:44:37 +08:00
|
|
|
|
using Canon.Core.Enums;
|
|
|
|
|
using Canon.Core.LexicalParser;
|
|
|
|
|
|
|
|
|
|
namespace Canon.Tests.LexicalParserTests;
|
|
|
|
|
|
|
|
|
|
public class DelimiterTests
|
|
|
|
|
{
|
|
|
|
|
[Theory]
|
|
|
|
|
[InlineData(",123", DelimiterType.Comma)]
|
2024-04-04 21:25:11 +08:00
|
|
|
|
// [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)
|
|
|
|
|
{
|
2024-03-15 12:00:47 +08:00
|
|
|
|
Lexer lexer = new(input);
|
|
|
|
|
List<SemanticToken> tokens = lexer.Tokenize();
|
2024-03-09 21:44:37 +08:00
|
|
|
|
|
2024-03-15 12:00:47 +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
|
|
|
|
}
|
|
|
|
|
}
|