mirror of
https://github.com/Smaug123/WoofWare.PrattParser
synced 2025-10-06 09:58:40 +00:00
Initial WIP commit
This commit is contained in:
27
PrattParser.Test/PrattParser.Test.fsproj
Normal file
27
PrattParser.Test/PrattParser.Test.fsproj
Normal file
@@ -0,0 +1,27 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
<IsPublishable>false</IsPublishable>
|
||||
<IsTestProject>true</IsTestProject>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="TestLexer.fs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="FsUnit" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0"/>
|
||||
<PackageReference Include="NUnit" Version="4.0.1"/>
|
||||
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0"/>
|
||||
<PackageReference Include="coverlet.collector" Version="6.0.0"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\PrattParser\PrattParser.fsproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
66
PrattParser.Test/TestLexer.fs
Normal file
66
PrattParser.Test/TestLexer.fs
Normal file
@@ -0,0 +1,66 @@
|
||||
namespace PrattParser.Test
|
||||
|
||||
open PrattParser
|
||||
open NUnit.Framework
|
||||
open FsUnitTyped
|
||||
|
||||
[<TestFixture>]
|
||||
module TestLexer =
|
||||
|
||||
[<Test>]
|
||||
let ``Lexer looks plausible`` () =
|
||||
let input = "g x y + a * func (b + 100)"
|
||||
|
||||
let expected =
|
||||
[
|
||||
{
|
||||
Type = TokenType.Var
|
||||
Trivia = (0, 1)
|
||||
}
|
||||
{
|
||||
Type = TokenType.Var
|
||||
Trivia = (2, 1)
|
||||
}
|
||||
{
|
||||
Type = TokenType.Var
|
||||
Trivia = (4, 1)
|
||||
}
|
||||
{
|
||||
Type = TokenType.Plus
|
||||
Trivia = (6, 1)
|
||||
}
|
||||
{
|
||||
Type = TokenType.Var
|
||||
Trivia = (8, 1)
|
||||
}
|
||||
{
|
||||
Type = TokenType.Times
|
||||
Trivia = (10, 1)
|
||||
}
|
||||
{
|
||||
Type = TokenType.Var
|
||||
Trivia = (12, 4)
|
||||
}
|
||||
{
|
||||
Type = TokenType.LeftBracket
|
||||
Trivia = (17, 1)
|
||||
}
|
||||
{
|
||||
Type = TokenType.Var
|
||||
Trivia = (18, 1)
|
||||
}
|
||||
{
|
||||
Type = TokenType.Plus
|
||||
Trivia = (20, 1)
|
||||
}
|
||||
{
|
||||
Type = TokenType.ConstInt
|
||||
Trivia = (22, 3)
|
||||
}
|
||||
{
|
||||
Type = TokenType.RightBracket
|
||||
Trivia = (25, 1)
|
||||
}
|
||||
]
|
||||
|
||||
Lexer.lex input |> shouldEqual expected
|
Reference in New Issue
Block a user