diff options
Diffstat (limited to 'test/lisp/simple-tests.el')
-rw-r--r-- | test/lisp/simple-tests.el | 79 |
1 files changed, 65 insertions, 14 deletions
diff --git a/test/lisp/simple-tests.el b/test/lisp/simple-tests.el index 6350bebeeea..97f425f6f48 100644 --- a/test/lisp/simple-tests.el +++ b/test/lisp/simple-tests.el @@ -321,7 +321,7 @@ See bug#35036." ;; Stay at BOB. (forward-line -1) (save-restriction - (narrow-to-region (point) (line-end-position)) + (narrow-to-region (point) (pos-eol)) (should-not (delete-indentation)) (should (equal (simple-test--buffer-substrings) '("" . " second "))) @@ -344,27 +344,23 @@ See bug#35036." (should (equal (simple-test--buffer-substrings) '(" first " . ""))) ;; Single line. - (should-not (delete-indentation - nil (line-beginning-position) (1- (point)))) + (should-not (delete-indentation nil (pos-bol) (1- (point)))) (should (equal (simple-test--buffer-substrings) '("" . " first "))) - (should-not (delete-indentation nil (1+ (point)) (line-end-position))) + (should-not (delete-indentation nil (1+ (point)) (pos-eol))) (should (equal (simple-test--buffer-substrings) '(" " . "first "))) - (should-not (delete-indentation - nil (line-beginning-position) (line-end-position))) + (should-not (delete-indentation nil (pos-bol) (pos-eol))) (should (equal (simple-test--buffer-substrings) '("" . " first "))) ;; Multiple lines. (goto-char (point-max)) (insert "\n second \n third \n fourth ") (goto-char (point-min)) - (should-not (delete-indentation - nil (line-end-position) (line-beginning-position 2))) + (should-not (delete-indentation nil (pos-eol) (pos-bol 2))) (should (equal (simple-test--buffer-substrings) '(" first" . " second \n third \n fourth "))) - (should-not (delete-indentation - nil (point) (1+ (line-beginning-position 2)))) + (should-not (delete-indentation nil (point) (1+ (pos-bol 2)))) (should (equal (simple-test--buffer-substrings) '(" first second" . " third \n fourth "))) ;; Prefix argument overrides region. @@ -808,7 +804,7 @@ See Bug#21722." (insert "a\nb\nc\nd\n") (goto-char (point-min)) (forward-line (1- target-line)) - (narrow-to-region (line-beginning-position) (line-end-position)) + (narrow-to-region (pos-bol) (pos-eol)) (should (equal (line-number-at-pos) 1)) (should (equal (line-number-at-pos nil t) target-line))))) @@ -817,7 +813,7 @@ See Bug#21722." (insert "a\nb\nc\nd\n") (goto-char (point-min)) (forward-line 2) - (narrow-to-region (line-beginning-position) (line-end-position)) + (narrow-to-region (pos-bol) (pos-eol)) (should (equal (line-number-at-pos) 1)) (line-number-at-pos nil t) (should (equal (line-number-at-pos) 1)))) @@ -966,10 +962,65 @@ See Bug#21722." (setq buffer-undo-list nil) (downcase-word 1) (should (= (length (delq nil (undo-make-selective-list 1 9))) 2)) - (should (= (length (delq nil (undo-make-selective-list 4 9))) 1)) - ;; FIXME this is the off-by-one error case. + ;; FIXME: These should give 0, but currently give 1. + ;;(should (= (length (delq nil (undo-make-selective-list 4 9))) 0)) ;;(should (= (length (delq nil (undo-make-selective-list 5 9))) 0)) (should (= (length (delq nil (undo-make-selective-list 6 9))) 0)))) +(ert-deftest test-yank-in-context () + (should + (equal + (with-temp-buffer + (sh-mode) + (insert "echo \"foo\"") + (kill-new "\"bar\"") + (goto-char 8) + (yank-in-context) + (buffer-string)) + "echo \"f\\\"bar\\\"oo\"")) + + (should + (equal + (with-temp-buffer + (sh-mode) + (insert "echo \"foo\"") + (kill-new "'bar'") + (goto-char 8) + (yank-in-context) + (buffer-string)) + "echo \"f'bar'oo\"")) + + (should + (equal + (with-temp-buffer + (sh-mode) + (insert "echo 'foo'") + (kill-new "'bar'") + (goto-char 8) + (yank-in-context) + (buffer-string)) + "echo 'f'\\''bar'\\''oo'"))) + +;;; Tests for `zap-to-char' + +(defmacro with-zap-to-char-test (original result &rest body) + (declare (indent 2) (debug (stringp stringp body))) + `(with-temp-buffer + (insert ,original) + (goto-char (point-min)) + ,@body + (should (equal (buffer-string) ,result)))) + +(ert-deftest simple-tests-zap-to-char () + (with-zap-to-char-test "abcde" "de" + (zap-to-char 1 ?c)) + (with-zap-to-char-test "abcde abc123" "123" + (zap-to-char 2 ?c)) + (let ((case-fold-search t)) + (with-zap-to-char-test "abcdeCXYZ" "deCXYZ" + (zap-to-char 1 ?C)) + (with-zap-to-char-test "abcdeCXYZ" "XYZ" + (zap-to-char 1 ?C 'interactive)))) + (provide 'simple-test) ;;; simple-tests.el ends here |