Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 21 additions & 9 deletions tests/FSharpx.Collections.Experimental.Tests/DListTest.fs
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,31 @@ module DListTest =

test "test DList.length should return 5" { DList.length expected |> Expect.equal "" 5 }

ptest "test ofSeq should create a DList from a seq" {
let test = seq { for i in 0..4 -> i }
DList.ofSeq test |> Expect.equal "" expected
test "test ofSeq should create a DList from a seq" {
let input = seq { for i in 0..4 -> i }

DList.ofSeq input
|> DList.toSeq
|> Seq.toList
|> Expect.equal "" [ 0; 1; 2; 3; 4 ]
}

ptest "test ofSeq should create a DList from a list" {
let test = [ for i in 0..4 -> i ]
DList.ofSeq test |> Expect.equal "" expected
test "test ofSeq should create a DList from a list" {
let input = [ for i in 0..4 -> i ]

DList.ofSeq input
|> DList.toSeq
|> Seq.toList
|> Expect.equal "" [ 0; 1; 2; 3; 4 ]
}

ptest "test ofSeq should create a DList from an array" {
let test = [| for i in 0..4 -> i |]
DList.ofSeq test |> Expect.equal "" expected
test "test ofSeq should create a DList from an array" {
let input = [| for i in 0..4 -> i |]

DList.ofSeq input
|> DList.toSeq
|> Seq.toList
|> Expect.equal "" [ 0; 1; 2; 3; 4 ]
}

test "test DList.cons should prepend 10 to the front of the original list" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,20 +191,6 @@ module SkewBinomialHeapTest =
}


//@@@@@@@@@@@@@@@@@@@
let iComparableGen() : Gen<IComparable> =
gen {
let! t =
Arb.generate
|> Gen.filter(fun x ->
match x :> obj with
| :? System.IComparable -> true
| _ -> false)

return t :> System.IComparable
}
//|> Arb.fromGen

let genDesc d =
match d with
| Some v -> Gen.constant v
Expand All @@ -213,7 +199,8 @@ module SkewBinomialHeapTest =
let emptyOnly d =
gen {
let! desc = genDesc d
let! s = Gen.listOf(Arb.generate<'T>)
let! n = Gen.choose(0, 12)
let! s = Gen.listOfLength n Arb.generate<int>

return
{ Heap =
Expand All @@ -227,7 +214,8 @@ module SkewBinomialHeapTest =
gen {
let! desc = genDesc d
let! t = Gen.elements [ true; false ]
let! s = Gen.nonEmptyListOf <| iComparableGen()
let! n = Gen.length1thru12
let! s = Gen.listOfLength n Arb.generate<int>

let! ndel =
if t then
Expand Down Expand Up @@ -302,7 +290,7 @@ module SkewBinomialHeapTest =
(Prop.forAll(Arb.fromGen heapStringGen)
<| fun (heap, orig) -> heap |> SkewBinomialHeap.toSeq |> Seq.toList = sortList heap orig)

ptestPropertyWithConfig
testPropertyWithConfig
config10k
"toList returns the same as toSeq |> List.ofSeq"
(Prop.forAll(comparableAndComparable())
Expand Down Expand Up @@ -535,7 +523,7 @@ module SkewBinomialHeapTest =
// |> SkewBinomialHeap.toList
// |> Expect.equal "" (orig1 |> List.append orig2 |> sortList heap1))

ptestPropertyWithConfig
testPropertyWithConfig
config10k
"merge throws when both heaps have diferent ordering"
(Prop.forAll(differentOrdered())
Expand Down Expand Up @@ -592,7 +580,7 @@ module SkewBinomialHeapTest =
////Maybe the distribution of the hash should be checked
////to avoid bad hashes, I don't know if that should be done as part of unit testPropertyWithConfig config10king

ptestPropertyWithConfig
testPropertyWithConfig
config10k
"Equality reflexivity"
(Prop.forAll(comparableAndComparable())
Expand Down
Loading