Skip to content

Commit

Permalink
Adding more tests for assocN
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed May 28, 2012
1 parent 791af50 commit 67ff653
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/FSharpx.Core/DataStructures/Vector.fs
@@ -1,4 +1,5 @@
module FSharpx.DataStructures.Vector
/// vector implementation ported from https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/PersistentVector.java
module FSharpx.DataStructures.Vector

open FSharpx

Expand Down
11 changes: 11 additions & 0 deletions tests/FSharpx.DataStructures.Tests/PersistentVectorTest.fs
Expand Up @@ -55,3 +55,14 @@ let ``vector with 30000 elements should be convertable to a seq``() =
let ``vector can be created from a seq``() =
let xs = [7;88;1;4;25;30]
ofSeq xs |> toSeq |> Seq.toList |> should equal xs

[<Test>]
let ``vector with 30000 elements should allow assocN``() =
let vector = ref empty
for i in 1..30000 do
vector := cons i (!vector)

for i in 1..30000 do
vector := assocN (i-1) (i*2) (!vector)

!vector |> toSeq |> Seq.toList |> should equal [for i in 1..30000 -> i*2]
12 changes: 12 additions & 0 deletions tests/FSharpx.DataStructures.Tests/TransientVectorTest.fs
Expand Up @@ -50,3 +50,15 @@ let ``vector with 30000 elements should be convertable to a seq``() =
vector := conj i (!vector)

!vector |> Seq.toList |> should equal [1..30000]


[<Test>]
let ``vector with 30000 elements should allow assocN``() =
let vector = ref empty
for i in 1..30000 do
vector := conj i (!vector)

for i in 1..30000 do
vector := assocN (i-1) (i*2) (!vector)

!vector |> Seq.toList |> should equal [for i in 1..30000 -> i*2]

0 comments on commit 67ff653

Please sign in to comment.