refactor tests a bit by putting LineGap-creation functionality into TestUtils.init, and make sure we also add a Unix-style newline to the end of the string if it doesn't already have one
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -17,10 +17,7 @@ struct
|
|||||||
|
|
||||||
fun applyChars (historyString, app) = updateLoop (0, historyString, app)
|
fun applyChars (historyString, app) = updateLoop (0, historyString, app)
|
||||||
|
|
||||||
fun appFromText text =
|
fun appFromText text = TestUtils.init text
|
||||||
let val buffer = LineGap.fromString text
|
|
||||||
in TestUtils.init buffer
|
|
||||||
end
|
|
||||||
|
|
||||||
fun loadFromFile (io, acc) =
|
fun loadFromFile (io, acc) =
|
||||||
case TextIO.inputLine io of
|
case TextIO.inputLine io of
|
||||||
@@ -36,22 +33,19 @@ struct
|
|||||||
str
|
str
|
||||||
end
|
end
|
||||||
|
|
||||||
val initialApp = appFromText initialText
|
|
||||||
|
|
||||||
val charEventTests = describe "CHAR_EVENT regressions"
|
val charEventTests = describe "CHAR_EVENT regressions"
|
||||||
[ test "SearchList.goToNum vector bounds regression (1)" (fn _ =>
|
[ test "SearchList.goToNum vector bounds regression (1)" (fn _ =>
|
||||||
let
|
let
|
||||||
val app = appFromText initialText
|
val app = TestUtils.init initialText
|
||||||
val history = "G12dk"
|
val history = "G12dk"
|
||||||
val newApp = applyChars (history, app)
|
val newApp = applyChars (history, app)
|
||||||
in
|
in
|
||||||
(* just expect that we do not fail or throw an exception *)
|
(* just expect that we do not fail or throw an exception *)
|
||||||
Expect.isTrue true
|
Expect.isTrue true
|
||||||
end)
|
end)
|
||||||
,
|
, test "No error raised when moving cursor up/down after deleting" (fn _ =>
|
||||||
test "idk yet" (fn _ =>
|
|
||||||
let
|
let
|
||||||
val app = appFromText initialText
|
val app = TestUtils.init initialText
|
||||||
val history =
|
val history =
|
||||||
"16G18ddjjjjjjjjjdkdkdkjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj"
|
"16G18ddjjjjjjjjjdkdkdkjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj"
|
||||||
val newApp = applyChars (history, app)
|
val newApp = applyChars (history, app)
|
||||||
|
|||||||
@@ -1,7 +1,18 @@
|
|||||||
structure TestUtils =
|
structure TestUtils =
|
||||||
struct
|
struct
|
||||||
fun init buffer =
|
fun withUnixLineEndings str =
|
||||||
AppType.init (buffer, 0, 0, Time.now ())
|
if String.size str > 0 andalso String.sub (str, String.size str - 1) = #"\n" then
|
||||||
|
str
|
||||||
|
else
|
||||||
|
str ^ "\n"
|
||||||
|
|
||||||
|
fun init bufferString =
|
||||||
|
let
|
||||||
|
val bufferString = withUnixLineEndings bufferString
|
||||||
|
val buffer = LineGap.fromString bufferString
|
||||||
|
in
|
||||||
|
AppType.init (buffer, 0, 0, Time.now ())
|
||||||
|
end
|
||||||
|
|
||||||
fun update (app, cmd) =
|
fun update (app, cmd) =
|
||||||
AppUpdate.update (app, cmd, Time.now ())
|
AppUpdate.update (app, cmd, Time.now ())
|
||||||
|
|||||||
Reference in New Issue
Block a user