amend bug resulting from previous refactoring (don't know origin of bug but I pressed undo in my editor and did the refactoring again, and this time all tests passed)
This commit is contained in:
2
LICENSE
2
LICENSE
@@ -1,4 +1,4 @@
|
||||
Copyright (C) 2023 by Humza Shahid <humzasaur@gmail.com>
|
||||
Copyright (C) 2024 by Humza Shahid <humzasaur@gmail.com>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted.
|
||||
|
||||
|
||||
519562
automerge.sml
519562
automerge.sml
File diff suppressed because it is too large
Load Diff
@@ -74,7 +74,7 @@ struct
|
||||
| [] => consLeft (curIdx, newString, left, right))
|
||||
| [] => consLeft (curIdx, newString, left, right)
|
||||
|
||||
fun insLeftLeaf (prevIdx, idx, newString, curIdx, right, hd, tail) =
|
||||
fun insLeft (prevIdx, idx, newString, curIdx, hd, tail, right) =
|
||||
(* The requested index is either:
|
||||
* - At the start of the left string
|
||||
* - In the middle of the left string
|
||||
@@ -129,7 +129,7 @@ struct
|
||||
}
|
||||
end
|
||||
|
||||
fun insRightLeaf (nextIdx, idx, newString, curIdx, left, hd, tail) =
|
||||
fun insRight (nextIdx, idx, newString, curIdx, left, hd, tail) =
|
||||
if idx = nextIdx then
|
||||
(* At end of next string. *)
|
||||
{ idx = curIdx
|
||||
@@ -168,6 +168,7 @@ struct
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
fun ins (idx, newString, curIdx, left, right) : t =
|
||||
if curIdx = idx then
|
||||
preferInsertLeft (curIdx, newString, left, right)
|
||||
@@ -186,8 +187,7 @@ struct
|
||||
* so move leftward one string. *)
|
||||
ins (idx, newString, prevIdx, tail, joinStartOfRight (hd, right))
|
||||
else
|
||||
(* Call function to insert at the current node in the zipper. *)
|
||||
insLeftLeaf (prevIdx, idx, newString, curIdx, right, hd, tail)
|
||||
insLeft (prevIdx, idx, newString, curIdx, hd, tail, right)
|
||||
end
|
||||
else
|
||||
(* Need to insert to the right. *)
|
||||
@@ -200,7 +200,7 @@ struct
|
||||
if idx > nextIdx then
|
||||
ins (idx, newString, nextIdx, joinEndOfLeft (hd, left), tail)
|
||||
else
|
||||
insRightLeaf (nextIdx, idx, newString, curIdx, right, hd, tail)
|
||||
insRight (nextIdx, idx, newString, curIdx, left, hd, tail)
|
||||
end
|
||||
|
||||
fun insert (idx, newString, buffer: t) =
|
||||
|
||||
13
utils.sml
13
utils.sml
@@ -88,14 +88,21 @@ fun main () =
|
||||
val svelte = runTxnsTime SvelteComponent.txns
|
||||
val rust = runTxnsTime RustCode.txns
|
||||
val seph = runTxnsTime SephBlog.txns
|
||||
val automerge = runTxnsTime automerge_arr
|
||||
val automerge = runTxnsTime AutomergePaper.txns
|
||||
|
||||
(* Tests for correctness; will fail if incorrect. *)
|
||||
(** Tests for insertion correctness (compare against rope). **)
|
||||
val _ = compareTxns SvelteComponent.txns
|
||||
val _ = print "svelte test passed\n"
|
||||
|
||||
val _ = compareTxns RustCode.txns
|
||||
val _ = print "rust test passed\n"
|
||||
|
||||
val _ = compareTxns SephBlog.txns
|
||||
val _ = compareTxns automerge_arr
|
||||
val _ = print "seph test passed\n"
|
||||
|
||||
val _ = compareTxns AutomergePaper.txns
|
||||
val _ = print "automerge test passed\n"
|
||||
|
||||
(* Tests for line metadata. *)
|
||||
(*
|
||||
@@ -110,7 +117,7 @@ fun main () =
|
||||
val _ = write ("out/seph23_gap.txt", seph)
|
||||
val _ = write ("out/automerge_gap.txt", automerge)
|
||||
in
|
||||
loop ()
|
||||
()
|
||||
end
|
||||
|
||||
val _ = main ()
|
||||
|
||||
Reference in New Issue
Block a user