c4189fd1b2
add: 词法分析器剩下数字、标识符的细节处理以及错误处理 Co-authored-by: duqoo <92306417+duqoo@users.noreply.github.com> Reviewed-on: PostGuard/Canon#15 Co-authored-by: Huaps <1183155719@qq.com> Co-committed-by: Huaps <1183155719@qq.com>
25 lines
781 B
C#
25 lines
781 B
C#
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)]
|
|
[InlineData("andand", true)]
|
|
public void TestParseIdentifier(string input, bool expectedResult)
|
|
{
|
|
Lexer lexer = new(input);
|
|
List<SemanticToken> tokens = lexer.Tokenize();
|
|
|
|
Assert.Single(tokens);
|
|
Assert.Equal(expectedResult, tokens.FirstOrDefault()?.TokenType == SemanticTokenType.Identifier);
|
|
}
|
|
}
|
|
}
|