feat: Parser Combinator库和词法分析器 (#2)
All checks were successful
Run unit test / Unit-Test (push) Successful in 41s
All checks were successful
Run unit test / Unit-Test (push) Successful in 41s
Reviewed-on: https://git.bupt-hpc.cn/jackfiled/CanonSharp/pulls/2 Co-authored-by: jackfiled <xcrenchangjun@outlook.com> Co-committed-by: jackfiled <xcrenchangjun@outlook.com>
This commit is contained in:
29
CanonSharp.Tests/CombinatorsTests/LinqTests.cs
Normal file
29
CanonSharp.Tests/CombinatorsTests/LinqTests.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using CanonSharp.Combinator.Abstractions;
|
||||
using CanonSharp.Combinator.Extensions;
|
||||
using static CanonSharp.Combinator.Text.TextParserBuilder;
|
||||
using CanonSharp.Tests.Utils;
|
||||
|
||||
namespace CanonSharp.Tests.CombinatorsTests;
|
||||
|
||||
public class LinqTests : ParserTestsBase
|
||||
{
|
||||
[Fact]
|
||||
public void SelectTest1()
|
||||
{
|
||||
Parser<char, string> parser = from token in Char('a')
|
||||
select token.ToString();
|
||||
ValidateSuccessfulResult(parser, "a", "a");
|
||||
ValidateFailedResult(parser, "b");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SelectManyTest1()
|
||||
{
|
||||
Parser<char, int> parser = from _1 in Char('a')
|
||||
from _2 in Char('b')
|
||||
from _3 in Char('c')
|
||||
select 123;
|
||||
ValidateSuccessfulResult(parser, 123, "abc");
|
||||
ValidateFailedResult(parser, "asd");
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user