mirror of
https://github.com/Smaug123/fsharp-vectors
synced 2025-10-08 04:48:40 +00:00
Initial commit
This commit is contained in:
66
Vector.Test/UnitTest1.fs
Normal file
66
Vector.Test/UnitTest1.fs
Normal 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
|
||||
|
25
Vector.Test/Vector.Test.fsproj
Normal file
25
Vector.Test/Vector.Test.fsproj
Normal 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>
|
Reference in New Issue
Block a user