Add 'brolib-sml/' from commit 'fd96032949434207dda3b288f48d7fe579f59e4e'
git-subtree-dir: brolib-sml git-subtree-mainline:64471ecf7fgit-subtree-split:fd96032949
This commit is contained in:
18
brolib-sml/tests/compare.mlb
Normal file
18
brolib-sml/tests/compare.mlb
Normal file
@@ -0,0 +1,18 @@
|
||||
$(SML_LIB)/basis/basis.mlb
|
||||
|
||||
ann
|
||||
"allowVectorExps true"
|
||||
in
|
||||
../data-sets/svelte.sml
|
||||
(* other datasets commented out
|
||||
* because they didn't detect any issues
|
||||
* and give much longer compile times
|
||||
../data-sets/rust.sml
|
||||
../data-sets/seph.sml
|
||||
../data-sets/automerge.sml
|
||||
*)
|
||||
end
|
||||
|
||||
../src/tiny_rope.sml
|
||||
../src/line_gap.sml
|
||||
compare_to_rope.sml
|
||||
90
brolib-sml/tests/compare_to_rope.sml
Normal file
90
brolib-sml/tests/compare_to_rope.sml
Normal file
@@ -0,0 +1,90 @@
|
||||
structure CompareToRope =
|
||||
struct
|
||||
fun compareTxns arr =
|
||||
Vector.foldli
|
||||
(fn (idx, (pos, delNum, insStr), (rope, gapBuffer)) =>
|
||||
let
|
||||
val _ = print ("txn number: " ^ Int.toString idx ^ "\n")
|
||||
val oldRope = rope
|
||||
val strSize = String.size insStr
|
||||
|
||||
val 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 =
|
||||
if delNum > 0 then LineGap.delete (pos, delNum, gapBuffer)
|
||||
else gapBuffer
|
||||
|
||||
val _ = LineGap.verifyIndex gapBuffer
|
||||
val _ = LineGap.verifyLines gapBuffer
|
||||
|
||||
val gapBuffer =
|
||||
if strSize > 0 then LineGap.insert (pos, insStr, gapBuffer)
|
||||
else gapBuffer
|
||||
|
||||
val _ = LineGap.verifyIndex gapBuffer
|
||||
val _ = LineGap.verifyLines 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
|
||||
val _ = compareTxns SvelteComponent.txns
|
||||
val _ = print "string contents and line metadata are equal for svelte\n"
|
||||
|
||||
(* compile times are much longer with the other datasets included
|
||||
* but running those datasets did not detect any issues after
|
||||
* all issues were fixed with Svelte.
|
||||
|
||||
* So comment these datasets out.
|
||||
val _ = compareTxns RustCode.txns
|
||||
val _ = print "string contents and line metadata are equal for rust\n"
|
||||
|
||||
val _ = compareTxns SephBlog.txns
|
||||
val _ = print "string contents and line metadata equal for seh"
|
||||
|
||||
val _ = compareTxns AutomergePaper.txns
|
||||
val _ = print "string contents and line metadata equal for automerge"
|
||||
*)
|
||||
in
|
||||
()
|
||||
end
|
||||
|
||||
val _ = main ()
|
||||
end
|
||||
Reference in New Issue
Block a user