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:
2024-05-25 15:05:40 +01:00
parent e9339908ef
commit 01496aa06f
4 changed files with 259799 additions and 259788 deletions

View File

@@ -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. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted.

519562
automerge.sml

File diff suppressed because it is too large Load Diff

View File

@@ -74,7 +74,7 @@ struct
| [] => consLeft (curIdx, newString, left, right)) | [] => consLeft (curIdx, newString, left, right))
| [] => 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: (* The requested index is either:
* - At the start of the left string * - At the start of the left string
* - In the middle of the left string * - In the middle of the left string
@@ -129,7 +129,7 @@ struct
} }
end end
fun insRightLeaf (nextIdx, idx, newString, curIdx, left, hd, tail) = fun insRight (nextIdx, idx, newString, curIdx, left, hd, tail) =
if idx = nextIdx then if idx = nextIdx then
(* At end of next string. *) (* At end of next string. *)
{ idx = curIdx { idx = curIdx
@@ -168,6 +168,7 @@ struct
} }
end end
fun ins (idx, newString, curIdx, left, right) : t = fun ins (idx, newString, curIdx, left, right) : t =
if curIdx = idx then if curIdx = idx then
preferInsertLeft (curIdx, newString, left, right) preferInsertLeft (curIdx, newString, left, right)
@@ -186,8 +187,7 @@ struct
* so move leftward one string. *) * so move leftward one string. *)
ins (idx, newString, prevIdx, tail, joinStartOfRight (hd, right)) ins (idx, newString, prevIdx, tail, joinStartOfRight (hd, right))
else else
(* Call function to insert at the current node in the zipper. *) insLeft (prevIdx, idx, newString, curIdx, hd, tail, right)
insLeftLeaf (prevIdx, idx, newString, curIdx, right, hd, tail)
end end
else else
(* Need to insert to the right. *) (* Need to insert to the right. *)
@@ -200,7 +200,7 @@ struct
if idx > nextIdx then if idx > nextIdx then
ins (idx, newString, nextIdx, joinEndOfLeft (hd, left), tail) ins (idx, newString, nextIdx, joinEndOfLeft (hd, left), tail)
else else
insRightLeaf (nextIdx, idx, newString, curIdx, right, hd, tail) insRight (nextIdx, idx, newString, curIdx, left, hd, tail)
end end
fun insert (idx, newString, buffer: t) = fun insert (idx, newString, buffer: t) =

View File

@@ -88,14 +88,21 @@ fun main () =
val svelte = runTxnsTime SvelteComponent.txns val svelte = runTxnsTime SvelteComponent.txns
val rust = runTxnsTime RustCode.txns val rust = runTxnsTime RustCode.txns
val seph = runTxnsTime SephBlog.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 correctness; will fail if incorrect. *)
(** Tests for insertion correctness (compare against rope). **) (** Tests for insertion correctness (compare against rope). **)
val _ = compareTxns SvelteComponent.txns val _ = compareTxns SvelteComponent.txns
val _ = print "svelte test passed\n"
val _ = compareTxns RustCode.txns val _ = compareTxns RustCode.txns
val _ = print "rust test passed\n"
val _ = compareTxns SephBlog.txns 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. *) (* Tests for line metadata. *)
(* (*
@@ -110,7 +117,7 @@ fun main () =
val _ = write ("out/seph23_gap.txt", seph) val _ = write ("out/seph23_gap.txt", seph)
val _ = write ("out/automerge_gap.txt", automerge) val _ = write ("out/automerge_gap.txt", automerge)
in in
loop () ()
end end
val _ = main () val _ = main ()