diff options
| author | Damien Cassou | 2017-04-09 12:46:57 +0200 |
|---|---|---|
| committer | Nicolas Petton | 2017-06-19 11:17:56 +0200 |
| commit | ae98cdf9431604d0f722f1db217ca06debfbb7b6 (patch) | |
| tree | 282b0658d520e638e6905f40153343de34259ff0 /test | |
| parent | dbe3e416af5d845dc774341eb66971ab1a72983b (diff) | |
| download | emacs-ae98cdf9431604d0f722f1db217ca06debfbb7b6.tar.gz emacs-ae98cdf9431604d0f722f1db217ca06debfbb7b6.zip | |
Add current-line in simple.el
* lisp/simple.el (current-line): New function.
* test/list/simple-tests.el: Add tests for current-line.
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/simple-tests.el | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/test/lisp/simple-tests.el b/test/lisp/simple-tests.el index 180dcc0a209..ad7aee1db17 100644 --- a/test/lisp/simple-tests.el +++ b/test/lisp/simple-tests.el | |||
| @@ -448,5 +448,54 @@ See Bug#21722." | |||
| 448 | (call-interactively #'eval-expression) | 448 | (call-interactively #'eval-expression) |
| 449 | (should (equal (current-message) "66 (#o102, #x42, ?B)")))))) | 449 | (should (equal (current-message) "66 (#o102, #x42, ?B)")))))) |
| 450 | 450 | ||
| 451 | (ert-deftest line-number-at-pos-in-widen-buffer () | ||
| 452 | (let ((target-line 3)) | ||
| 453 | (with-temp-buffer | ||
| 454 | (insert "a\nb\nc\nd\n") | ||
| 455 | (goto-char (point-min)) | ||
| 456 | (forward-line (1- target-line)) | ||
| 457 | (should (equal (line-number-at-pos) target-line)) | ||
| 458 | (should (equal (line-number-at-pos nil t) target-line))))) | ||
| 459 | |||
| 460 | (ert-deftest line-number-at-pos-in-narrow-buffer () | ||
| 461 | (let ((target-line 3)) | ||
| 462 | (with-temp-buffer | ||
| 463 | (insert "a\nb\nc\nd\n") | ||
| 464 | (goto-char (point-min)) | ||
| 465 | (forward-line (1- target-line)) | ||
| 466 | (narrow-to-region (line-beginning-position) (line-end-position)) | ||
| 467 | (should (equal (line-number-at-pos) 1)) | ||
| 468 | (should (equal (line-number-at-pos nil t) target-line))))) | ||
| 469 | |||
| 470 | (ert-deftest line-number-at-pos-keeps-restriction () | ||
| 471 | (with-temp-buffer | ||
| 472 | (insert "a\nb\nc\nd\n") | ||
| 473 | (goto-char (point-min)) | ||
| 474 | (forward-line 2) | ||
| 475 | (narrow-to-region (line-beginning-position) (line-end-position)) | ||
| 476 | (should (equal (line-number-at-pos) 1)) | ||
| 477 | (line-number-at-pos nil t) | ||
| 478 | (should (equal (line-number-at-pos) 1)))) | ||
| 479 | |||
| 480 | (ert-deftest line-number-at-pos-keeps-point () | ||
| 481 | (let (pos) | ||
| 482 | (with-temp-buffer | ||
| 483 | (insert "a\nb\nc\nd\n") | ||
| 484 | (goto-char (point-min)) | ||
| 485 | (forward-line 2) | ||
| 486 | (setq pos (point)) | ||
| 487 | (line-number-at-pos) | ||
| 488 | (line-number-at-pos nil t) | ||
| 489 | (should (equal pos (point)))))) | ||
| 490 | |||
| 491 | (ert-deftest line-number-at-pos-when-passing-point () | ||
| 492 | (let (pos) | ||
| 493 | (with-temp-buffer | ||
| 494 | (insert "a\nb\nc\nd\n") | ||
| 495 | (should (equal (line-number-at-pos 1) 1)) | ||
| 496 | (should (equal (line-number-at-pos 3) 2)) | ||
| 497 | (should (equal (line-number-at-pos 5) 3)) | ||
| 498 | (should (equal (line-number-at-pos 7) 4))))) | ||
| 499 | |||
| 451 | (provide 'simple-test) | 500 | (provide 'simple-test) |
| 452 | ;;; simple-test.el ends here | 501 | ;;; simple-test.el ends here |