add: Variable declaration tests.
This commit is contained in:
parent
ed36546b30
commit
eedbd5e7e5
|
@ -103,6 +103,20 @@ public class CombinatorParserTests : ParserTestsBase
|
|||
parser = Token('a').Skip1Till(Token('b'));
|
||||
ValidateSuccessfulResult(parser, 'b', "aaab");
|
||||
ValidateFailedResult(parser, "b");
|
||||
|
||||
parser = Token('a').SkipTill(Choice(
|
||||
Token('b'), Token('c')));
|
||||
|
||||
ValidateSuccessfulResult(parser, 'b', "aaab");
|
||||
ValidateSuccessfulResult(parser, 'c', "ac");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SkipTillManyTest()
|
||||
{
|
||||
IParser<char, IEnumerable<char>> parser = Token('a').SkipTill(Token('b')).Many();
|
||||
|
||||
ValidateSuccessfulResult(parser, ['b', 'b'], "aaabaab");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
20
CanonSharp.Tests/ParserTests/VariableDeclarationTests.cs
Normal file
20
CanonSharp.Tests/ParserTests/VariableDeclarationTests.cs
Normal file
|
@ -0,0 +1,20 @@
|
|||
using CanonSharp.Pascal.Parser;
|
||||
using CanonSharp.Pascal.SyntaxTree;
|
||||
using CanonSharp.Tests.Utils;
|
||||
|
||||
namespace CanonSharp.Tests.ParserTests;
|
||||
|
||||
public class VariableDeclarationTests : GrammarParserTestBase
|
||||
{
|
||||
[Theory]
|
||||
[InlineData("boolean", "boolean")]
|
||||
[InlineData("integer", "integer")]
|
||||
[InlineData("char", "char")]
|
||||
[InlineData("real", "real")]
|
||||
public void TypeParseTest(string input, string value)
|
||||
{
|
||||
TypeNode node = RunParser<TypeNode>(GrammarParser.TypeParser(), input);
|
||||
Assert.Equal(value, node.TypeToken.LiteralValue);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
using CanonSharp.Combinator.Extensions;
|
||||
using CanonSharp.Pascal.Scanner;
|
||||
|
||||
namespace CanonSharp.Tests.LexicalAnalyzerTests;
|
||||
namespace CanonSharp.Tests.ReaderTests;
|
||||
|
||||
public class StringReadStateTests
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user