add deletion to compare-testing (deletion does not work properly yet, as expected)
This commit is contained in:
@@ -1,69 +1,74 @@
|
|||||||
structure CompareToRope =
|
structure CompareToRope =
|
||||||
struct
|
struct
|
||||||
fun compareTxns arr =
|
fun compareTxns arr =
|
||||||
Vector.foldli
|
Vector.foldli
|
||||||
(fn (idx, (pos, delNum, insStr), (rope, gapBuffer)) =>
|
(fn (idx, (pos, delNum, insStr), (rope, gapBuffer)) =>
|
||||||
let
|
let
|
||||||
val _ = print ("idx: " ^ Int.toString idx ^ "\n")
|
val _ = print ("idx: " ^ Int.toString idx ^ "\n")
|
||||||
val oldRope = rope
|
val oldRope = rope
|
||||||
val strSize = String.size insStr
|
val strSize = String.size insStr
|
||||||
|
|
||||||
val rope =
|
val rope =
|
||||||
if strSize > 0 then TinyRope.insert (pos, insStr, rope) else rope
|
if delNum > 0 then TinyRope.delete (pos, delNum, rope) else rope
|
||||||
|
val rope =
|
||||||
|
if strSize > 0 then TinyRope.insert (pos, insStr, rope) else rope
|
||||||
|
|
||||||
val gapBuffer =
|
val gapBuffer =
|
||||||
if strSize > 0 then LineGap.insert (pos, insStr, gapBuffer)
|
if delNum > 0 then LineGap.delete (pos, delNum, gapBuffer)
|
||||||
else gapBuffer
|
else gapBuffer
|
||||||
|
val gapBuffer =
|
||||||
|
if strSize > 0 then LineGap.insert (pos, insStr, gapBuffer)
|
||||||
|
else gapBuffer
|
||||||
|
|
||||||
val ropeString = TinyRope.toString rope
|
val ropeString = TinyRope.toString rope
|
||||||
val gapBufferString = LineGap.toString gapBuffer
|
val gapBufferString = LineGap.toString gapBuffer
|
||||||
in
|
in
|
||||||
if ropeString = gapBufferString then
|
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)
|
(rope, gapBuffer)
|
||||||
end
|
else
|
||||||
end) (TinyRope.empty, LineGap.empty) arr
|
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 () =
|
fun main () =
|
||||||
let
|
let
|
||||||
val (rope, gap) = compareTxns SvelteComponent.txns
|
val (rope, gap) = compareTxns SvelteComponent.txns
|
||||||
val _ = print "string contents are equal\n"
|
val _ = print "string contents are equal\n"
|
||||||
val _ = LineGap.verifyLines gap
|
val _ = LineGap.verifyLines gap
|
||||||
(*
|
(*
|
||||||
val _ = compareTxns Rust.txns
|
val _ = compareTxns Rust.txns
|
||||||
val _ = compareTxns Seph.txns
|
val _ = compareTxns Seph.txns
|
||||||
val _ = compareTxns Automerge.txns
|
val _ = compareTxns Automerge.txns
|
||||||
*)
|
*)
|
||||||
in
|
in
|
||||||
()
|
()
|
||||||
end
|
end
|
||||||
|
|
||||||
val _ = main ()
|
val _ = main ()
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user