add a test for 'PersistentVector.delete' (even though the 'PersistentVector.merge' helper function is unimplemented)

This commit is contained in:
2026-01-17 23:27:36 +00:00
parent ee58556bde
commit 1c947eab7d
2 changed files with 37 additions and 3 deletions

View File

@@ -550,7 +550,7 @@ struct
fun delete (start, finish, tree) = fun delete (start, finish, tree) =
let let
val matchAfterFinish = nextMatch (finish, tree, 1) val matchAfterFinish = nextMatch (finish, tree, 1)
val left = splitRight (start, tree) val left = splitLeft (start, tree)
in in
if matchAfterFinish = ~1 then if matchAfterFinish = ~1 then
(* there is no match after 'finish', so just split left. (* there is no match after 'finish', so just split left.

View File

@@ -284,5 +284,39 @@ struct
end) end)
] ]
val tests = [appendTests, toListTests, splitLeftTests] val deleteTests = describe "PersistentVector.delete"
[test
"returns the left side of the vector \
\when 'finish' is greater than any element in the vector"
(fn _ =>
let
(* arrange *)
val inputList =
[ {start = 1, finish = 1}
, {start = 2, finish = 2}
, {start = 3, finish = 3}
, {start = 4, finish = 4}
, {start = 5, finish = 5}
, {start = 6, finish = 6}
, {start = 7, finish = 7}
, {start = 8, finish = 8}
]
val pv = PersistentVector.fromList inputList
(* act *)
val pv = PersistentVector.delete (5, 9, pv)
(* assert *)
val outputList = PersistentVector.toList pv
val expectedOutput =
[ {start = 1, finish = 1}
, {start = 2, finish = 2}
, {start = 3, finish = 3}
, {start = 4, finish = 4}
]
in
Expect.isTrue (outputList = expectedOutput)
end)]
val tests = [appendTests, toListTests, splitLeftTests, deleteTests]
end end