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:
@@ -1,7 +1,18 @@
|
||||
structure TestUtils =
|
||||
struct
|
||||
fun init buffer =
|
||||
AppType.init (buffer, 0, 0, Time.now ())
|
||||
fun withUnixLineEndings str =
|
||||
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) =
|
||||
AppUpdate.update (app, cmd, Time.now ())
|
||||
|
||||
Reference in New Issue
Block a user