This repository has been archived by the owner on Aug 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bc07c36
commit 72ee98f
Showing
4 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
|
||
<IsPackable>false</IsPackable> | ||
<GenerateProgramFile>false</GenerateProgramFile> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Compile Include="Tests.fs" /> | ||
<Compile Include="TokenTest.fs" /> | ||
<Compile Include="TokenRepositoryTest.fs" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Expecto" Version="9.0.1" /> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" /> | ||
<PackageReference Include="xunit" Version="2.4.1" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="coverlet.collector" Version="3.1.0"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Pirate.Lexer.F\Pirate.Lexer.F.fsproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module Tests | ||
|
||
open System | ||
open Xunit | ||
|
||
[<Fact>] | ||
let ``My test`` () = | ||
Assert.True(true) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
module Pirate.Lexer.F.Test.TokenRepositoryTest | ||
|
||
open Xunit | ||
open Pirate.Lexer.F | ||
open Pirate.Lexer.F.Tokens.Enums | ||
|
||
[<Fact>] | ||
let ShouldMakeNumber () = | ||
let tokenRepository = new TokenRepository(new KeyWordService()) | ||
let text = "123" | ||
let position = 0 | ||
|
||
let result = tokenRepository.MakeNumber(text, position) | ||
|
||
Assert.Equal(3, result.Position) | ||
Assert.Equal(VALUE, result.Token.TokenGroup); | ||
Assert.Equal(INT, result.Token.TokenType); | ||
Assert.Equal(123, result.Token.Value |> unbox<int>) | ||
|
||
[<Fact>] | ||
let ShouldMakeFloat () = | ||
let tokenRepository = new TokenRepository(new KeyWordService()) | ||
let text = "123.456" | ||
let position = 0 | ||
|
||
let result = tokenRepository.MakeNumber(text, position) | ||
|
||
Assert.Equal(7, result.Position) | ||
Assert.Equal(VALUE, result.Token.TokenGroup) | ||
Assert.Equal(FLOAT, result.Token.TokenType) | ||
Assert.Equal(123.456, result.Token.Value |> unbox<float>) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module Pirate.Lexer.F.Test.TokenTest | ||
|
||
open Xunit | ||
open Pirate.Lexer.F.Tokens | ||
open Pirate.Lexer.F.Tokens.Enums | ||
|
||
[<Fact>] | ||
let ShouldMatchToken () = | ||
Token(VALUE, INT, 123).Matches(TokenType.INT, 123) |> Assert.True | ||
|
||
[<Fact>] | ||
let ShouldNotMatchToken () = | ||
Token(VALUE, INT, 123).Matches(TokenType.INT, 456) |> Assert.False | ||
|
||
|