add a couple of more tests, and revert persistent-vector.sml to how it was before adding rope-like metadata
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -71,5 +71,4 @@ test/test-utils.sml
|
|||||||
test/normal-move.sml
|
test/normal-move.sml
|
||||||
test/normal-delete.sml
|
test/normal-delete.sml
|
||||||
test/regression.sml
|
test/regression.sml
|
||||||
test/persistent-vector-tests.sml
|
|
||||||
test/test.sml
|
test/test.sml
|
||||||
|
|||||||
@@ -4066,7 +4066,27 @@ struct
|
|||||||
andalso actualCursor7 = expectedCursorIdx
|
andalso actualCursor7 = expectedCursorIdx
|
||||||
in
|
in
|
||||||
Expect.isTrue (stringsAreExpected andalso cursorsAreExpected)
|
Expect.isTrue (stringsAreExpected andalso cursorsAreExpected)
|
||||||
end)]
|
end)
|
||||||
|
, test
|
||||||
|
"deletes middle word if word is a punctuation word \
|
||||||
|
\surrounded by spaces"
|
||||||
|
(fn _ =>
|
||||||
|
let
|
||||||
|
(* arrange *)
|
||||||
|
val originalString = "hello !#%&( world\n"
|
||||||
|
val app = TestUtils.init originalString
|
||||||
|
val app = AppWith.idx (app, 9)
|
||||||
|
|
||||||
|
(* act *)
|
||||||
|
val {buffer, cursorIdx, ...} = TestUtils.updateMany (app, "diw")
|
||||||
|
|
||||||
|
(* assert *)
|
||||||
|
val actualString = LineGap.toString buffer
|
||||||
|
val expectedString = "hello world\n"
|
||||||
|
in
|
||||||
|
Expect.isTrue (actualString = expectedString)
|
||||||
|
end)
|
||||||
|
]
|
||||||
|
|
||||||
val tests =
|
val tests =
|
||||||
[ dhDelete
|
[ dhDelete
|
||||||
|
|||||||
@@ -1,107 +0,0 @@
|
|||||||
structure PersistentVectorTests =
|
|
||||||
struct
|
|
||||||
open Railroad
|
|
||||||
open Railroad.Test
|
|
||||||
|
|
||||||
structure Pv = PersistentVector
|
|
||||||
|
|
||||||
val appendTests = describe "PersistentVector.append"
|
|
||||||
[test "appends new values to end" (fn _ =>
|
|
||||||
let
|
|
||||||
(* arrange *)
|
|
||||||
val pv = Pv.fromList [(1, 1), (3, 3)]
|
|
||||||
|
|
||||||
(* act *)
|
|
||||||
val pv = Pv.append (5, 7, pv)
|
|
||||||
|
|
||||||
(* assert *)
|
|
||||||
val outputList = Pv.toList pv
|
|
||||||
val expectedList = [(1, 1), (3, 3), (5, 7)]
|
|
||||||
in
|
|
||||||
Expect.isTrue (outputList = expectedList)
|
|
||||||
end)]
|
|
||||||
|
|
||||||
fun printList lst =
|
|
||||||
let
|
|
||||||
val str =
|
|
||||||
List.map
|
|
||||||
(fn (start, finish) =>
|
|
||||||
"(" ^ Int.toString start ^ ", " ^ Int.toString finish ^ ")") lst
|
|
||||||
val str = "[" ^ String.concatWith ", " str ^ "]\n"
|
|
||||||
in
|
|
||||||
print str
|
|
||||||
end
|
|
||||||
|
|
||||||
val deleteTests = describe "PersistentVector.delete"
|
|
||||||
[ test
|
|
||||||
"deletes last value correctly \
|
|
||||||
\when only last value is in deletion range"
|
|
||||||
(fn _ =>
|
|
||||||
let
|
|
||||||
(* arrange *)
|
|
||||||
val pv = Pv.fromList [(0, 0), (3, 3), (5, 5)]
|
|
||||||
|
|
||||||
(* act *)
|
|
||||||
val pv = Pv.delete (5, 1, pv)
|
|
||||||
|
|
||||||
(* assert *)
|
|
||||||
val outputList = Pv.toList pv
|
|
||||||
val expectedList = [(0, 0), (3, 3)]
|
|
||||||
in
|
|
||||||
Expect.isTrue (outputList = expectedList)
|
|
||||||
end)
|
|
||||||
, test
|
|
||||||
"deletes second-last value correctly \
|
|
||||||
\and adjusts last value as expected"
|
|
||||||
(fn _ =>
|
|
||||||
let
|
|
||||||
(* arrange *)
|
|
||||||
val pv = Pv.fromList [(0, 0), (3, 3), (5, 5), (7, 7)]
|
|
||||||
|
|
||||||
(* act *)
|
|
||||||
val pv = Pv.delete (4, 1, pv)
|
|
||||||
|
|
||||||
(* assert *)
|
|
||||||
val outputList = Pv.toList pv
|
|
||||||
val expectedList = [(0, 0), (3, 3), (6, 6)]
|
|
||||||
in
|
|
||||||
Expect.isTrue (outputList = expectedList)
|
|
||||||
end)
|
|
||||||
, test
|
|
||||||
"deletes middle value correctly \
|
|
||||||
\and adjusts values-after-middle as well"
|
|
||||||
(fn _ =>
|
|
||||||
let
|
|
||||||
(* arrange *)
|
|
||||||
val pv = Pv.fromList [(0, 0), (3, 3), (5, 5)]
|
|
||||||
|
|
||||||
(* act *)
|
|
||||||
val pv = Pv.delete (3, 1, pv)
|
|
||||||
|
|
||||||
(* assert *)
|
|
||||||
val outputList = Pv.toList pv
|
|
||||||
val expectedList = [(0, 0), (4, 4)]
|
|
||||||
in
|
|
||||||
Expect.isTrue (outputList = expectedList)
|
|
||||||
end)
|
|
||||||
, test
|
|
||||||
"deletes first value correctly \
|
|
||||||
\and adjusts values-after-first as well"
|
|
||||||
(fn _ =>
|
|
||||||
let
|
|
||||||
(* arrange *)
|
|
||||||
val pv = Pv.fromList [(0, 0), (3, 3), (5, 5)]
|
|
||||||
|
|
||||||
(* act *)
|
|
||||||
val pv = Pv.delete (0, 1, pv)
|
|
||||||
|
|
||||||
(* assert *)
|
|
||||||
val outputList = Pv.toList pv
|
|
||||||
val expectedList = [(2, 2), (4, 4)]
|
|
||||||
in
|
|
||||||
Expect.isTrue (outputList = expectedList)
|
|
||||||
end)
|
|
||||||
]
|
|
||||||
|
|
||||||
val tests = [appendTests, deleteTests]
|
|
||||||
end
|
|
||||||
@@ -5,12 +5,12 @@ struct
|
|||||||
|
|
||||||
fun main () =
|
fun main () =
|
||||||
let
|
let
|
||||||
val tests = List.concat
|
val tests =
|
||||||
|
List.concat
|
||||||
[ NormalMove.tests
|
[ NormalMove.tests
|
||||||
, NormalDelete.tests
|
, NormalDelete.tests
|
||||||
, Regression.tests
|
, Regression.tests
|
||||||
, RegexTests.tests
|
, RegexTests.tests
|
||||||
, PersistentVectorTests.tests
|
|
||||||
]
|
]
|
||||||
val tests = concat tests
|
val tests = concat tests
|
||||||
in
|
in
|
||||||
|
|||||||
Reference in New Issue
Block a user