Initial commit

This commit is contained in:
Smaug123
2020-05-02 12:57:03 +01:00
commit 4132a7b3f7
6 changed files with 219 additions and 0 deletions

66
Vector.Test/UnitTest1.fs Normal file
View File

@@ -0,0 +1,66 @@
namespace Vector.Test
open Vector
open NUnit.Framework
open FsUnitTyped
[<TestFixture>]
module TestVector =
[<Test>]
let example1 () =
let v1 =
Vector.empty
|> Vector.cons 3
|> Vector.cons 5
|> Vector.cons 6
v1 |> Vector.toList |> shouldEqual [6 ; 5 ; 3]
let v2 = Vector.empty |> Vector.cons "hi" |> Vector.cons "bye"
v2 |> Vector.toList |> shouldEqual ["bye" ; "hi"]
match Vector.empty with
| Empty () -> failwith ""
//| Vec (a, b) -> failwith "" -- doesn't compile
match v1 with
| Vec (a , b) ->
a |> shouldEqual 6
b |> Vector.toList |> shouldEqual [5 ; 3]
let v1 =
Vector.empty
|> Vector.cons 3
|> Vector.cons 5
|> Vector.cons 6
let twice = Vector.append v1 v1
let otherTwice =
Vector.empty
|> Vector.cons 3
|> Vector.cons 5
|> Vector.cons 6
|> Vector.cons 3
|> Vector.cons 5
|> Vector.cons 6
twice |> Vector.toList
|> shouldEqual (otherTwice |> Vector.toList)
twice
|> Vector.cast
|> Vector.cast<S<S<_>>, _, _>
|> Vector.cast<S<S<S<S<_>>>>, _, _>
|> Vector.cast
|> shouldEqual otherTwice
[<Test>]
let foo () =
let v1 = Vector.empty |> Vector.cons 1
let twice = Vector.append v1 v1
let twiceAgain = Vector.empty |> Vector.cons 1 |> Vector.cons 1
twice
|> Vector.cast
|> Vector.cast
|> shouldEqual twiceAgain

View File

@@ -0,0 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<IsPackable>false</IsPackable>
<GenerateProgramFile>false</GenerateProgramFile>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="FsUnit" Version="3.8.1" />
<PackageReference Include="nunit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.15.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
</ItemGroup>
<ItemGroup>
<Compile Include="UnitTest1.fs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Vector\Vector.fsproj" />
</ItemGroup>
</Project>