2025-08-04 07:14:00 +01:00
|
|
|
structure Regression =
|
|
|
|
|
struct
|
|
|
|
|
open Railroad
|
|
|
|
|
open Railroad.Test
|
|
|
|
|
|
|
|
|
|
fun updateLoop (pos, str, app) =
|
|
|
|
|
if pos = String.size str then
|
|
|
|
|
app
|
|
|
|
|
else
|
|
|
|
|
let
|
|
|
|
|
val chr = String.sub (str, pos)
|
2025-08-04 09:03:47 +01:00
|
|
|
val () = ExceptionLogger.addCommand (InputMsg.CHAR_EVENT chr)
|
2025-08-04 07:14:00 +01:00
|
|
|
val app = AppUpdate.update (app, InputMsg.CHAR_EVENT chr)
|
|
|
|
|
in
|
|
|
|
|
updateLoop (pos + 1, str, app)
|
|
|
|
|
end
|
|
|
|
|
|
2025-08-04 08:33:48 +01:00
|
|
|
fun applyChars (historyString, app) = updateLoop (0, historyString, app)
|
2025-08-04 07:14:00 +01:00
|
|
|
|
|
|
|
|
fun appFromText text =
|
|
|
|
|
let val buffer = LineGap.fromString text
|
|
|
|
|
in AppType.init (buffer, 0, 0)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
fun loadFromFile (io, acc) =
|
|
|
|
|
case TextIO.inputLine io of
|
|
|
|
|
SOME line => loadFromFile (io, acc ^ line)
|
|
|
|
|
| NONE => acc
|
|
|
|
|
|
|
|
|
|
val initialText =
|
|
|
|
|
let
|
|
|
|
|
val io = TextIO.openIn "temp.txt"
|
|
|
|
|
val str = loadFromFile (io, "")
|
|
|
|
|
val () = TextIO.closeIn io
|
|
|
|
|
in
|
|
|
|
|
str
|
|
|
|
|
end
|
|
|
|
|
|
2025-08-04 08:33:48 +01:00
|
|
|
val initialApp = appFromText initialText
|
|
|
|
|
|
2025-08-04 07:14:00 +01:00
|
|
|
val charEventTests = describe "CHAR_EVENT regressions"
|
2025-08-04 08:33:48 +01:00
|
|
|
[test "SearchList.goToNum vector bounds regression (1)" (fn _ =>
|
|
|
|
|
let
|
|
|
|
|
val app = appFromText initialText
|
|
|
|
|
val history = "G12dk"
|
|
|
|
|
val history = "100G55dkz33dk"
|
|
|
|
|
val newApp = applyChars (history, app)
|
|
|
|
|
in
|
|
|
|
|
(* just expect that we do not fail or throw an exception *)
|
|
|
|
|
Expect.isTrue true
|
|
|
|
|
end)]
|
2025-08-04 07:14:00 +01:00
|
|
|
|
|
|
|
|
val tests = [charEventTests]
|
|
|
|
|
end
|