diff options
Diffstat (limited to 'test/src')
| -rw-r--r-- | test/src/editfns-tests.el | 68 |
1 files changed, 34 insertions, 34 deletions
diff --git a/test/src/editfns-tests.el b/test/src/editfns-tests.el index c3f825c6149..3da9d4e8acd 100644 --- a/test/src/editfns-tests.el +++ b/test/src/editfns-tests.el | |||
| @@ -289,7 +289,7 @@ | |||
| 289 | (narrow-to-region 8 13) | 289 | (narrow-to-region 8 13) |
| 290 | (goto-char 12) | 290 | (goto-char 12) |
| 291 | (should (looking-at " \\'")) | 291 | (should (looking-at " \\'")) |
| 292 | (replace-buffer-contents source) | 292 | (replace-region-contents (point-min) (point-max) source) |
| 293 | (should (looking-at " \\'"))) | 293 | (should (looking-at " \\'"))) |
| 294 | (should (equal (marker-buffer marker) (current-buffer))) | 294 | (should (equal (marker-buffer marker) (current-buffer))) |
| 295 | (should (equal (marker-position marker) 16))) | 295 | (should (equal (marker-position marker) 16))) |
| @@ -306,7 +306,7 @@ | |||
| 306 | (let ((source (current-buffer))) | 306 | (let ((source (current-buffer))) |
| 307 | (with-temp-buffer | 307 | (with-temp-buffer |
| 308 | (insert "foo BAR baz qux") | 308 | (insert "foo BAR baz qux") |
| 309 | (replace-buffer-contents source) | 309 | (replace-region-contents (point-min) (point-max) source) |
| 310 | (should (equal-including-properties | 310 | (should (equal-including-properties |
| 311 | (buffer-string) | 311 | (buffer-string) |
| 312 | "foo bar baz qux")))))) | 312 | "foo bar baz qux")))))) |
| @@ -318,44 +318,44 @@ | |||
| 318 | (switch-to-buffer "b") | 318 | (switch-to-buffer "b") |
| 319 | (insert-char (char-from-name "SMILE")) | 319 | (insert-char (char-from-name "SMILE")) |
| 320 | (insert "5678") | 320 | (insert "5678") |
| 321 | (replace-buffer-contents "a") | 321 | (replace-region-contents (point-min) (point-max) (get-buffer "a")) |
| 322 | (should (equal (buffer-substring-no-properties (point-min) (point-max)) | 322 | (should (equal (buffer-substring-no-properties (point-min) (point-max)) |
| 323 | (concat (string (char-from-name "SMILE")) "1234")))) | 323 | (concat (string (char-from-name "SMILE")) "1234")))) |
| 324 | 324 | ||
| 325 | (defun editfns--replace-region (from to string) | ||
| 326 | (save-excursion | ||
| 327 | (save-restriction | ||
| 328 | (narrow-to-region from to) | ||
| 329 | (let ((buf (current-buffer))) | ||
| 330 | (with-temp-buffer | ||
| 331 | (let ((str-buf (current-buffer))) | ||
| 332 | (insert string) | ||
| 333 | (with-current-buffer buf | ||
| 334 | (replace-buffer-contents str-buf)))))))) | ||
| 335 | |||
| 336 | (ert-deftest editfns-tests--replace-region () | 325 | (ert-deftest editfns-tests--replace-region () |
| 337 | ;; :expected-result :failed | 326 | ;; :expected-result :failed |
| 338 | (with-temp-buffer | 327 | (with-temp-buffer |
| 339 | (insert "here is some text") | 328 | (let ((tmpbuf (current-buffer))) |
| 340 | (let ((m5n (copy-marker (+ (point-min) 5))) | 329 | (insert " be ") |
| 341 | (m5a (copy-marker (+ (point-min) 5) t)) | 330 | (narrow-to-region (+ (point-min) 2) (- (point-max) 2)) |
| 342 | (m6n (copy-marker (+ (point-min) 6))) | 331 | (dolist (args `((,tmpbuf) |
| 343 | (m6a (copy-marker (+ (point-min) 6) t)) | 332 | (,(vector tmpbuf (point-min) (point-max))) |
| 344 | (m7n (copy-marker (+ (point-min) 7))) | 333 | (,"be") |
| 345 | (m7a (copy-marker (+ (point-min) 7) t))) | 334 | (,(vector tmpbuf (point-min) (point-max)) 0) |
| 346 | (editfns--replace-region (+ (point-min) 5) (+ (point-min) 7) "be") | 335 | (,"be" 0))) |
| 347 | (should (equal (buffer-string) "here be some text")) | 336 | (with-temp-buffer |
| 348 | (should (equal (point) (point-max))) | 337 | (insert "here is some text") |
| 349 | ;; Markers before the replaced text stay before. | 338 | (let ((m5n (copy-marker (+ (point-min) 5))) |
| 350 | (should (= m5n (+ (point-min) 5))) | 339 | (m5a (copy-marker (+ (point-min) 5) t)) |
| 351 | (should (= m5a (+ (point-min) 5))) | 340 | (m6n (copy-marker (+ (point-min) 6))) |
| 352 | ;; Markers in the replaced text can end up at either end, depending | 341 | (m6a (copy-marker (+ (point-min) 6) t)) |
| 353 | ;; on whether they're advance-after-insert or not. | 342 | (m7n (copy-marker (+ (point-min) 7))) |
| 354 | (should (= m6n (+ (point-min) 5))) | 343 | (m7a (copy-marker (+ (point-min) 7) t))) |
| 355 | (should (<= (+ (point-min) 5) m6a (+ (point-min) 7))) | 344 | (apply #'replace-region-contents |
| 356 | ;; Markers after the replaced text stay after. | 345 | (+ (point-min) 5) (+ (point-min) 7) args) |
| 357 | (should (= m7n (+ (point-min) 7))) | 346 | (should (equal (buffer-string) "here be some text")) |
| 358 | (should (= m7a (+ (point-min) 7)))))) | 347 | (should (equal (point) (point-max))) |
| 348 | ;; Markers before the replaced text stay before. | ||
| 349 | (should (= m5n (+ (point-min) 5))) | ||
| 350 | (should (= m5a (+ (point-min) 5))) | ||
| 351 | ;; Markers in the replaced text can end up at either end, depending | ||
| 352 | ;; on whether they're advance-after-insert or not. | ||
| 353 | (should (= m6n (+ (point-min) 5))) | ||
| 354 | (should (<= (+ (point-min) 5) m6a (+ (point-min) 7))) | ||
| 355 | ;; Markers after the replaced text stay after. | ||
| 356 | (should (= m7n (+ (point-min) 7))) | ||
| 357 | (should (= m7a (+ (point-min) 7))))) | ||
| 358 | (widen))))) | ||
| 359 | 359 | ||
| 360 | (ert-deftest delete-region-undo-markers-1 () | 360 | (ert-deftest delete-region-undo-markers-1 () |
| 361 | "Make sure we don't end up with freed markers reachable from Lisp." | 361 | "Make sure we don't end up with freed markers reachable from Lisp." |