2024-06-30 00:07:45 +01:00
|
|
|
structure CompareToRope =
|
|
|
|
|
struct
|
2024-06-30 00:50:38 +01:00
|
|
|
fun compareTxns arr =
|
|
|
|
|
Vector.foldli
|
|
|
|
|
(fn (idx, (pos, delNum, insStr), (rope, gapBuffer)) =>
|
|
|
|
|
let
|
|
|
|
|
val _ = print ("idx: " ^ Int.toString idx ^ "\n")
|
|
|
|
|
val oldRope = rope
|
|
|
|
|
val strSize = String.size insStr
|
|
|
|
|
|
|
|
|
|
val rope =
|
|
|
|
|
if strSize > 0 then TinyRope.insert (pos, insStr, rope) else rope
|
|
|
|
|
|
|
|
|
|
val gapBuffer =
|
|
|
|
|
if strSize > 0 then LineGap.insert (pos, insStr, gapBuffer)
|
|
|
|
|
else gapBuffer
|
|
|
|
|
|
|
|
|
|
val ropeString = TinyRope.toString rope
|
|
|
|
|
val gapBufferString = LineGap.toString gapBuffer
|
|
|
|
|
in
|
|
|
|
|
if ropeString = gapBufferString then
|
|
|
|
|
(rope, gapBuffer)
|
|
|
|
|
else
|
|
|
|
|
let
|
|
|
|
|
val _ = print
|
|
|
|
|
("difference detected at txn number: " ^ (Int.toString idx)
|
|
|
|
|
^ "\n")
|
|
|
|
|
val txn = String.concat
|
|
|
|
|
[ "offending txn: \n"
|
|
|
|
|
, "pos: "
|
|
|
|
|
, Int.toString pos
|
|
|
|
|
, ", delNum: "
|
|
|
|
|
, Int.toString delNum
|
|
|
|
|
, ", insStr: |"
|
|
|
|
|
, insStr
|
|
|
|
|
, "|\n"
|
|
|
|
|
]
|
|
|
|
|
val _ = print txn
|
|
|
|
|
|
|
|
|
|
val _ = print "before offending string: \n"
|
|
|
|
|
val _ = print (TinyRope.toString oldRope)
|
|
|
|
|
val _ = print "\n"
|
|
|
|
|
|
|
|
|
|
val _ = print "rope string: \n"
|
|
|
|
|
val _ = print (ropeString ^ "\n")
|
|
|
|
|
val _ = print "gap string: \n"
|
|
|
|
|
val _ = print (gapBufferString ^ "\n")
|
|
|
|
|
val _ = raise Empty
|
|
|
|
|
in
|
|
|
|
|
(rope, gapBuffer)
|
|
|
|
|
end
|
|
|
|
|
end) (TinyRope.empty, LineGap.empty) arr
|
|
|
|
|
|
|
|
|
|
fun main () =
|
|
|
|
|
let
|
2024-06-30 02:05:48 +01:00
|
|
|
val (rope, gap) = compareTxns SvelteComponent.txns
|
2024-06-30 15:14:21 +01:00
|
|
|
val _ = print "string contents are equal\n"
|
2024-06-30 02:05:48 +01:00
|
|
|
val _ = LineGap.verifyLines gap
|
2024-06-30 00:50:38 +01:00
|
|
|
(*
|
|
|
|
|
val _ = compareTxns Rust.txns
|
|
|
|
|
val _ = compareTxns Seph.txns
|
|
|
|
|
val _ = compareTxns Automerge.txns
|
|
|
|
|
*)
|
2024-06-30 00:07:45 +01:00
|
|
|
in
|
2024-06-30 00:50:38 +01:00
|
|
|
()
|
2024-06-30 00:07:45 +01:00
|
|
|
end
|
2024-06-30 00:50:38 +01:00
|
|
|
|
|
|
|
|
val _ = main ()
|
2024-06-30 00:07:45 +01:00
|
|
|
end
|