branch: externals/compat
commit 821e251409c03f1e43dbb3d5739aece5e23e8d2f
Author: Daniel Mendler <[email protected]>
Commit: Daniel Mendler <[email protected]>
Test line-number-at-pos
---
compat-26.el | 2 +-
compat-tests.el | 9 +++++++++
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/compat-26.el b/compat-26.el
index 48261b663d..54a3254732 100644
--- a/compat-26.el
+++ b/compat-26.el
@@ -49,7 +49,7 @@ Concatenate the results by altering them (using `nconc').
SEQUENCE may be a list, a vector, a boolean vector, or a string."
(apply #'nconc (mapcar func sequence)))
-(compat-defun line-number-at-pos (&optional position absolute) ;; <UNTESTED>
+(compat-defun line-number-at-pos (&optional position absolute) ;; <OK>
"Handle optional argument ABSOLUTE:
If the buffer is narrowed, the return value by default counts the lines
diff --git a/compat-tests.el b/compat-tests.el
index ce03aa684b..1866b33be4 100644
--- a/compat-tests.el
+++ b/compat-tests.el
@@ -53,6 +53,15 @@
(setq list (funcall sym list "first" 1 #'string=))
(should (eq (compat-call plist-get list "first" #'string=) 1))))
+(ert-deftest line-number-at-pos ()
+ (with-temp-buffer
+ (insert "\n\n\n")
+ (narrow-to-region (1+ (point-min)) (point-max))
+ (should-equal 1 (compat-call line-number-at-pos (point-min)))
+ (should-equal 2 (compat-call line-number-at-pos (1+ (point-min))))
+ (should-equal 2 (compat-call line-number-at-pos (point-min) 'abs))
+ (should-equal 3 (compat-call line-number-at-pos (1+ (point-min)) 'abs))))
+
(defvar compat-test-map-1
(let ((map (make-sparse-keymap)))
(define-key map (kbd "C-x C-f") #'find-file)