2024-03-13 16:19:07 +08:00
|
|
|
|
using Canon.Core.Enums;
|
|
|
|
|
using Canon.Core.LexicalParser;
|
|
|
|
|
|
|
|
|
|
namespace Canon.Tests.LexicalParserTests
|
|
|
|
|
{
|
|
|
|
|
public class IdentifierTests
|
|
|
|
|
{
|
|
|
|
|
[Theory]
|
|
|
|
|
[InlineData("identifier", true)]
|
|
|
|
|
[InlineData("_identifier", true)]
|
|
|
|
|
[InlineData("identifier123", true)]
|
|
|
|
|
[InlineData("identifier_with_underscores", true)]
|
|
|
|
|
[InlineData("IdentifierWithCamelCase", true)]
|
2024-04-04 21:25:11 +08:00
|
|
|
|
[InlineData("andand", true)]
|
2024-03-13 16:19:07 +08:00
|
|
|
|
public void TestParseIdentifier(string input, bool expectedResult)
|
|
|
|
|
{
|
2024-03-15 12:00:47 +08:00
|
|
|
|
Lexer lexer = new(input);
|
|
|
|
|
List<SemanticToken> tokens = lexer.Tokenize();
|
|
|
|
|
|
2024-04-04 21:25:11 +08:00
|
|
|
|
Assert.Single(tokens);
|
2024-03-15 12:00:47 +08:00
|
|
|
|
Assert.Equal(expectedResult, tokens.FirstOrDefault()?.TokenType == SemanticTokenType.Identifier);
|
2024-03-13 16:19:07 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|