add tests checking that persistent-vector.sml appends properly, as it is meant to

This commit is contained in:
2026-01-15 13:03:23 +00:00
parent ac3b987c42
commit 290cc65a52

View File

@@ -45,19 +45,54 @@ struct
loopInRange lst
end
val initial =
let
val f = PersistentVector.append
val pv = PersistentVector.empty
val appendTests = describe "PersistentVector.append"
[ test "contains appended values in range" (fn _ =>
let
(* arrange *)
val f = PersistentVector.append
val pv = PersistentVector.empty
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)
in
pv
end
(* 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)
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