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-delete.sml
|
||||
test/regression.sml
|
||||
test/persistent-vector-tests.sml
|
||||
test/test.sml
|
||||
|
||||
@@ -4001,72 +4001,92 @@ struct
|
||||
]
|
||||
|
||||
val diwDelete = describe "delete motion 'diw' (delete inside word)"
|
||||
[test
|
||||
"deletes middle word when middle word is \
|
||||
\an alphanumeric word surrounded on both sides by spaces"
|
||||
(fn _ =>
|
||||
let
|
||||
(* arrange *)
|
||||
val originalString = "hello abc_123 world\n"
|
||||
val app = TestUtils.init originalString
|
||||
[ test
|
||||
"deletes middle word when middle word is \
|
||||
\an alphanumeric word surrounded on both sides by spaces"
|
||||
(fn _ =>
|
||||
let
|
||||
(* arrange *)
|
||||
val originalString = "hello abc_123 world\n"
|
||||
val app = TestUtils.init originalString
|
||||
|
||||
val app1 = AppWith.idx (app, 6)
|
||||
val app2 = AppWith.idx (app, 7)
|
||||
val app3 = AppWith.idx (app, 8)
|
||||
val app4 = AppWith.idx (app, 9)
|
||||
val app5 = AppWith.idx (app, 10)
|
||||
val app6 = AppWith.idx (app, 11)
|
||||
val app7 = AppWith.idx (app, 12)
|
||||
val app1 = AppWith.idx (app, 6)
|
||||
val app2 = AppWith.idx (app, 7)
|
||||
val app3 = AppWith.idx (app, 8)
|
||||
val app4 = AppWith.idx (app, 9)
|
||||
val app5 = AppWith.idx (app, 10)
|
||||
val app6 = AppWith.idx (app, 11)
|
||||
val app7 = AppWith.idx (app, 12)
|
||||
|
||||
(* act *)
|
||||
val app1 = TestUtils.updateMany (app1, "diw")
|
||||
val app2 = TestUtils.updateMany (app2, "diw")
|
||||
val app3 = TestUtils.updateMany (app3, "diw")
|
||||
val app4 = TestUtils.updateMany (app4, "diw")
|
||||
val app5 = TestUtils.updateMany (app5, "diw")
|
||||
val app6 = TestUtils.updateMany (app6, "diw")
|
||||
val app7 = TestUtils.updateMany (app7, "diw")
|
||||
(* act *)
|
||||
val app1 = TestUtils.updateMany (app1, "diw")
|
||||
val app2 = TestUtils.updateMany (app2, "diw")
|
||||
val app3 = TestUtils.updateMany (app3, "diw")
|
||||
val app4 = TestUtils.updateMany (app4, "diw")
|
||||
val app5 = TestUtils.updateMany (app5, "diw")
|
||||
val app6 = TestUtils.updateMany (app6, "diw")
|
||||
val app7 = TestUtils.updateMany (app7, "diw")
|
||||
|
||||
(* assert *)
|
||||
val expectedString = "hello world\n"
|
||||
val expectedCursorIdx = 6
|
||||
(* assert *)
|
||||
val expectedString = "hello world\n"
|
||||
val expectedCursorIdx = 6
|
||||
|
||||
val actualString1 = LineGap.toString (#buffer app1)
|
||||
val actualString2 = LineGap.toString (#buffer app2)
|
||||
val actualString3 = LineGap.toString (#buffer app3)
|
||||
val actualString4 = LineGap.toString (#buffer app4)
|
||||
val actualString5 = LineGap.toString (#buffer app5)
|
||||
val actualString6 = LineGap.toString (#buffer app6)
|
||||
val actualString7 = LineGap.toString (#buffer app7)
|
||||
val actualString1 = LineGap.toString (#buffer app1)
|
||||
val actualString2 = LineGap.toString (#buffer app2)
|
||||
val actualString3 = LineGap.toString (#buffer app3)
|
||||
val actualString4 = LineGap.toString (#buffer app4)
|
||||
val actualString5 = LineGap.toString (#buffer app5)
|
||||
val actualString6 = LineGap.toString (#buffer app6)
|
||||
val actualString7 = LineGap.toString (#buffer app7)
|
||||
|
||||
val stringsAreExpected =
|
||||
actualString1 = expectedString
|
||||
andalso actualString2 = expectedString
|
||||
andalso actualString3 = expectedString
|
||||
andalso actualString4 = expectedString
|
||||
andalso actualString5 = expectedString
|
||||
andalso actualString6 = expectedString
|
||||
andalso actualString7 = expectedString
|
||||
val stringsAreExpected =
|
||||
actualString1 = expectedString
|
||||
andalso actualString2 = expectedString
|
||||
andalso actualString3 = expectedString
|
||||
andalso actualString4 = expectedString
|
||||
andalso actualString5 = expectedString
|
||||
andalso actualString6 = expectedString
|
||||
andalso actualString7 = expectedString
|
||||
|
||||
val actualCursor1 = #cursorIdx app1
|
||||
val actualCursor2 = #cursorIdx app2
|
||||
val actualCursor3 = #cursorIdx app3
|
||||
val actualCursor4 = #cursorIdx app4
|
||||
val actualCursor5 = #cursorIdx app5
|
||||
val actualCursor6 = #cursorIdx app6
|
||||
val actualCursor7 = #cursorIdx app7
|
||||
val actualCursor1 = #cursorIdx app1
|
||||
val actualCursor2 = #cursorIdx app2
|
||||
val actualCursor3 = #cursorIdx app3
|
||||
val actualCursor4 = #cursorIdx app4
|
||||
val actualCursor5 = #cursorIdx app5
|
||||
val actualCursor6 = #cursorIdx app6
|
||||
val actualCursor7 = #cursorIdx app7
|
||||
|
||||
val cursorsAreExpected =
|
||||
actualCursor1 = expectedCursorIdx
|
||||
andalso actualCursor2 = expectedCursorIdx
|
||||
andalso actualCursor3 = expectedCursorIdx
|
||||
andalso actualCursor4 = expectedCursorIdx
|
||||
andalso actualCursor5 = expectedCursorIdx
|
||||
andalso actualCursor6 = expectedCursorIdx
|
||||
andalso actualCursor7 = expectedCursorIdx
|
||||
in
|
||||
Expect.isTrue (stringsAreExpected andalso cursorsAreExpected)
|
||||
end)]
|
||||
val cursorsAreExpected =
|
||||
actualCursor1 = expectedCursorIdx
|
||||
andalso actualCursor2 = expectedCursorIdx
|
||||
andalso actualCursor3 = expectedCursorIdx
|
||||
andalso actualCursor4 = expectedCursorIdx
|
||||
andalso actualCursor5 = expectedCursorIdx
|
||||
andalso actualCursor6 = expectedCursorIdx
|
||||
andalso actualCursor7 = expectedCursorIdx
|
||||
in
|
||||
Expect.isTrue (stringsAreExpected andalso cursorsAreExpected)
|
||||
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 =
|
||||
[ 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,13 +5,13 @@ struct
|
||||
|
||||
fun main () =
|
||||
let
|
||||
val tests = List.concat
|
||||
[ NormalMove.tests
|
||||
, NormalDelete.tests
|
||||
, Regression.tests
|
||||
, RegexTests.tests
|
||||
, PersistentVectorTests.tests
|
||||
]
|
||||
val tests =
|
||||
List.concat
|
||||
[ NormalMove.tests
|
||||
, NormalDelete.tests
|
||||
, Regression.tests
|
||||
, RegexTests.tests
|
||||
]
|
||||
val tests = concat tests
|
||||
in
|
||||
runWithConfig [Configuration.PrintPassed false] tests
|
||||
|
||||
Reference in New Issue
Block a user