2024-08-13 14:46:11 +08:00
|
|
|
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()
|
|
|
|
{
|
2024-08-18 12:01:27 +08:00
|
|
|
IParser<char, string> parser = from token in Char('a')
|
2024-08-13 14:46:11 +08:00
|
|
|
select token.ToString();
|
|
|
|
ValidateSuccessfulResult(parser, "a", "a");
|
|
|
|
ValidateFailedResult(parser, "b");
|
|
|
|
}
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
public void SelectManyTest1()
|
|
|
|
{
|
2024-08-18 12:01:27 +08:00
|
|
|
IParser<char, int> parser = from _1 in Char('a')
|
2024-08-13 14:46:11 +08:00
|
|
|
from _2 in Char('b')
|
|
|
|
from _3 in Char('c')
|
|
|
|
select 123;
|
|
|
|
ValidateSuccessfulResult(parser, 123, "abc");
|
|
|
|
ValidateFailedResult(parser, "asd");
|
|
|
|
}
|
|
|
|
}
|