jackfiled
4b6635796c
Co-authored-by: Huaps <1183155719@qq.com> Co-authored-by: duqoo <92306417+duqoo@users.noreply.github.com> Reviewed-on: PostGuard/Canon#38
27 lines
933 B
C#
27 lines
933 B
C#
using Canon.Core.Enums;
|
|
using Canon.Core.LexicalParser;
|
|
using Canon.Tests.Utils;
|
|
using Canon.Core.Abstractions;
|
|
namespace Canon.Tests.LexicalParserTests
|
|
{
|
|
public class IdentifierTests
|
|
{
|
|
private readonly ILexer _lexer = new Lexer();
|
|
|
|
[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)
|
|
{
|
|
IEnumerable<SemanticToken> tokensEnumerable = _lexer.Tokenize(new StringSourceReader(input));
|
|
List<SemanticToken> tokens = tokensEnumerable.ToList();
|
|
|
|
Assert.Equal(expectedResult, tokens.FirstOrDefault()?.TokenType == SemanticTokenType.Identifier);
|
|
}
|
|
}
|
|
}
|