add tests checking that persistent-vector.sml appends properly, as it is meant to
This commit is contained in:
@@ -45,19 +45,54 @@ struct
|
|||||||
loopInRange lst
|
loopInRange lst
|
||||||
end
|
end
|
||||||
|
|
||||||
val initial =
|
val appendTests = describe "PersistentVector.append"
|
||||||
let
|
[ test "contains appended values in range" (fn _ =>
|
||||||
val f = PersistentVector.append
|
let
|
||||||
val pv = PersistentVector.empty
|
(* arrange *)
|
||||||
|
val f = PersistentVector.append
|
||||||
|
val pv = PersistentVector.empty
|
||||||
|
|
||||||
val pv = f (1, 3, pv)
|
(* act *)
|
||||||
val pv = f (5, 7, pv)
|
val pv = f (1, 3, pv)
|
||||||
val pv = f (9, 13, pv)
|
val pv = f (5, 7, pv)
|
||||||
val pv = f (19, 27, pv)
|
val pv = f (9, 13, pv)
|
||||||
val pv = f (33, 33, pv)
|
val pv = f (19, 27, pv)
|
||||||
in
|
val pv = f (33, 33, pv)
|
||||||
pv
|
|
||||||
end
|
|
||||||
|
|
||||||
val tests = []
|
(* assert *)
|
||||||
|
(* we split the list into several smaller lists
|
||||||
|
* and then concatenate at the end
|
||||||
|
* so that the formatter does not cause
|
||||||
|
* each list element to take its own line *)
|
||||||
|
val indicesInRange1 = [1, 2, 3, 5, 6, 7, 9]
|
||||||
|
val indicesInRange2 = [10, 11, 12, 13, 19, 20]
|
||||||
|
val indicesInRange3 = [21, 22, 23, 24, 25, 26, 27, 33]
|
||||||
|
|
||||||
|
val indicesInRange =
|
||||||
|
List.concat [indicesInRange1, indicesInRange2, indicesInRange3]
|
||||||
|
in
|
||||||
|
isInRange (indicesInRange, pv)
|
||||||
|
end)
|
||||||
|
, test "does not contain values in range that were not appended" (fn _ =>
|
||||||
|
let
|
||||||
|
(* arrange *)
|
||||||
|
val f = PersistentVector.append
|
||||||
|
val pv = PersistentVector.empty
|
||||||
|
|
||||||
|
(* act *)
|
||||||
|
val pv = f (1, 3, pv)
|
||||||
|
val pv = f (5, 7, pv)
|
||||||
|
val pv = f (9, 13, pv)
|
||||||
|
val pv = f (19, 27, pv)
|
||||||
|
val pv = f (33, 33, pv)
|
||||||
|
|
||||||
|
(* assert *)
|
||||||
|
val indicesNotInRange =
|
||||||
|
[0, 4, 8, 14, 15, 16, 17, 18, 28, 29, 30, 31, 32, 34, 35]
|
||||||
|
in
|
||||||
|
isNotInRange (indicesNotInRange, pv)
|
||||||
|
end)
|
||||||
|
]
|
||||||
|
|
||||||
|
val tests = [appendTests]
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user