diff --git a/test/normal-delete-tests.sml b/test/normal-delete-tests.sml index 4b24999..a88537f 100644 --- a/test/normal-delete-tests.sml +++ b/test/normal-delete-tests.sml @@ -5986,7 +5986,6 @@ struct (actualString = expectedString andalso cursorIdx = expectedCursorIdx) end) - , test "decrements subsequent matches in search list \ \when we delete prior to last match" @@ -6019,6 +6018,103 @@ struct val expectedNewSearchList = [{start = 5, finish = 9}, {start = 11, finish = 15}] + val assertion = + oldSearchList = expectedOldSearchList + andalso newSearchList = expectedNewSearchList + in + Expect.isTrue assertion + end) + , test "recognises new match when there is a match after deletion" (fn _ => + let + (* arrange *) + val originalIdx = 8 + val originalString = "hhello, ello\n" + + val app = TestUtils.init originalString + val app = AppWith.idx (app, originalIdx) + + val app = TestUtils.updateMany (app, "/hello") + val app = AppUpdate.update (app, InputMsg.KEY_ENTER, Time.now ()) + + (* act *) + val newApp = TestUtils.updateMany (app, "dN") + + (* assert *) + val oldSearchList = #searchList app + val oldSearchList = PersistentVector.toList oldSearchList + val newSearchList = #searchList newApp + val newSearchList = PersistentVector.toList newSearchList + + val expectedOldSearchList = [{start = 1, finish = 5}] + val expectedNewSearchList = [{start = 0, finish = 4}] + + val assertion = + oldSearchList = expectedOldSearchList + andalso newSearchList = expectedNewSearchList + in + Expect.isTrue assertion + end) + , test + "shortens existing match when existing match should shorten after deletion" + (fn _ => + let + (* arrange *) + val originalIdx = 7 + val originalString = "test ooooooo hi there\n" + + val app = TestUtils.init originalString + val app = AppWith.idx (app, originalIdx) + + val app = TestUtils.updateMany (app, "/o+") + val app = AppUpdate.update (app, InputMsg.KEY_ENTER, Time.now ()) + + (* act *) + val newApp = TestUtils.updateMany (app, "dN") + + (* assert *) + val oldSearchList = #searchList app + val oldSearchList = PersistentVector.toList oldSearchList + + val newSearchList = #searchList newApp + val newSearchList = PersistentVector.toList newSearchList + + val expectedOldSearchList = [{start = 5, finish = 11}] + val expectedNewSearchList = [{start = 5, finish = 9}] + + val assertion = + oldSearchList = expectedOldSearchList + andalso newSearchList = expectedNewSearchList + in + Expect.isTrue assertion + end) + , test + "deletes match in search list \ + \when match no longer exists in buffer after deletion" + (fn _ => + let + (* arrange *) + val originalIdx = 9 + val originalString = "hello world test again\n" + + val app = TestUtils.init originalString + val app = AppWith.idx (app, originalIdx) + + val app = TestUtils.updateMany (app, "/o") + val app = AppUpdate.update (app, InputMsg.KEY_ENTER, Time.now ()) + + (* act *) + val newApp = TestUtils.updateMany (app, "dN") + + (* assert *) + val oldSearchList = #searchList app + val oldSearchList = PersistentVector.toList oldSearchList + val newSearchList = #searchList newApp + val newSearchList = PersistentVector.toList newSearchList + + val expectedOldSearchList = + [{start = 4, finish = 4}, {start = 7, finish = 7}] + val expectedNewSearchList = [{start = 4, finish = 4}] + val assertion = oldSearchList = expectedOldSearchList andalso newSearchList = expectedNewSearchList