diff options
| author | smerten <smerten@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2012-09-20 21:28:53 +0000 |
|---|---|---|
| committer | smerten <smerten@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2012-09-20 21:28:53 +0000 |
| commit | c205dbbe1dc393976c67fee9f97b194cb2af2c6b (patch) | |
| tree | 298f127420f43df35c6a8b60e84835f864389474 /docutils/tools/editors/emacs/tests | |
| parent | 53495e041da4dbd3b6bf8af458961bf11a29fbe9 (diff) | |
| download | docutils-c205dbbe1dc393976c67fee9f97b194cb2af2c6b.tar.gz | |
Add support for `imenu` and `which-func-mode`. Remember setting
`which-func-modes` for this feature to work.
Automated calculations of section title faces replaced by `defface`.
Remove superfluous `rst-portable-mark-active-p`.
Refactoring.
Add support for `testcover`.
git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@7515 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
Diffstat (limited to 'docutils/tools/editors/emacs/tests')
| -rw-r--r-- | docutils/tools/editors/emacs/tests/adjust-section.el | 5 | ||||
| -rw-r--r-- | docutils/tools/editors/emacs/tests/adornment.el | 5 | ||||
| -rw-r--r-- | docutils/tools/editors/emacs/tests/buffer.el | 1 | ||||
| -rw-r--r-- | docutils/tools/editors/emacs/tests/cl.el | 5 | ||||
| -rw-r--r-- | docutils/tools/editors/emacs/tests/comment.el | 5 | ||||
| -rw-r--r-- | docutils/tools/editors/emacs/tests/fill.el | 5 | ||||
| -rw-r--r-- | docutils/tools/editors/emacs/tests/font-lock.el | 5 | ||||
| -rw-r--r-- | docutils/tools/editors/emacs/tests/imenu.el | 111 | ||||
| -rw-r--r-- | docutils/tools/editors/emacs/tests/indent.el | 5 | ||||
| -rw-r--r-- | docutils/tools/editors/emacs/tests/init.el | 31 | ||||
| -rw-r--r-- | docutils/tools/editors/emacs/tests/items.el | 5 | ||||
| -rw-r--r-- | docutils/tools/editors/emacs/tests/movement.el | 5 | ||||
| -rw-r--r-- | docutils/tools/editors/emacs/tests/re.el | 5 | ||||
| -rw-r--r-- | docutils/tools/editors/emacs/tests/shift.el | 5 | ||||
| -rw-r--r-- | docutils/tools/editors/emacs/tests/toc.el | 7 | ||||
| -rw-r--r-- | docutils/tools/editors/emacs/tests/tree.el | 202 |
16 files changed, 370 insertions, 37 deletions
diff --git a/docutils/tools/editors/emacs/tests/adjust-section.el b/docutils/tools/editors/emacs/tests/adjust-section.el index 726a22d3c..3c673b29c 100644 --- a/docutils/tools/editors/emacs/tests/adjust-section.el +++ b/docutils/tools/editors/emacs/tests/adjust-section.el @@ -1,9 +1,8 @@ ;; Tests for rst-adjust (add-to-list 'load-path ".") -(load "ert-buffer" nil t) -(add-to-list 'load-path "..") -(load "rst.el" nil t) +(load "init" nil t) +(init-rst-ert t) (ert-deftest adjust-section-asserts () "Check some assertions." diff --git a/docutils/tools/editors/emacs/tests/adornment.el b/docutils/tools/editors/emacs/tests/adornment.el index 14cd229e7..10d18c07e 100644 --- a/docutils/tools/editors/emacs/tests/adornment.el +++ b/docutils/tools/editors/emacs/tests/adornment.el @@ -1,9 +1,8 @@ ;; Tests for various functions handling adornments (add-to-list 'load-path ".") -(load "ert-buffer" nil t) -(add-to-list 'load-path "..") -(load "rst.el" nil t) +(load "init" nil t) +(init-rst-ert t) (ert-deftest adornment-asserts () "Check some assertions." diff --git a/docutils/tools/editors/emacs/tests/buffer.el b/docutils/tools/editors/emacs/tests/buffer.el index 23aad45c4..088db73ef 100644 --- a/docutils/tools/editors/emacs/tests/buffer.el +++ b/docutils/tools/editors/emacs/tests/buffer.el @@ -1,6 +1,5 @@ ;;; buffer.el --- Test the test support for buffers - (add-to-list 'load-path ".") (load "ert-buffer" nil t) diff --git a/docutils/tools/editors/emacs/tests/cl.el b/docutils/tools/editors/emacs/tests/cl.el index 5708c3a7e..794cbb6a7 100644 --- a/docutils/tools/editors/emacs/tests/cl.el +++ b/docutils/tools/editors/emacs/tests/cl.el @@ -1,7 +1,8 @@ ;; Tests for replacement functions for `cl.el' -(add-to-list 'load-path "..") -(load "rst.el" nil t) +(add-to-list 'load-path ".") +(load "init" nil t) +(init-rst-ert nil) (ert-deftest rst-signum () "Test `rst-signum'." diff --git a/docutils/tools/editors/emacs/tests/comment.el b/docutils/tools/editors/emacs/tests/comment.el index 80d791578..0070aeb9b 100644 --- a/docutils/tools/editors/emacs/tests/comment.el +++ b/docutils/tools/editors/emacs/tests/comment.el @@ -1,9 +1,8 @@ ;; Tests for comment handling (add-to-list 'load-path ".") -(load "ert-buffer" nil t) -(add-to-list 'load-path "..") -(load "rst.el" nil t) +(load "init" nil t) +(init-rst-ert t) (ert-deftest comment-asserts () "Check some assertions." diff --git a/docutils/tools/editors/emacs/tests/fill.el b/docutils/tools/editors/emacs/tests/fill.el index 704f42bb6..1a29cd638 100644 --- a/docutils/tools/editors/emacs/tests/fill.el +++ b/docutils/tools/editors/emacs/tests/fill.el @@ -1,9 +1,8 @@ ;; Tests for functions around filling (add-to-list 'load-path ".") -(load "ert-buffer" nil t) -(add-to-list 'load-path "..") -(load "rst.el" nil t) +(load "init" nil t) +(init-rst-ert t) (ert-deftest fill-asserts () "Check some assertions." diff --git a/docutils/tools/editors/emacs/tests/font-lock.el b/docutils/tools/editors/emacs/tests/font-lock.el index f20ce4acc..fb7fc6715 100644 --- a/docutils/tools/editors/emacs/tests/font-lock.el +++ b/docutils/tools/editors/emacs/tests/font-lock.el @@ -1,9 +1,8 @@ ;; Tests for font-locking code (add-to-list 'load-path ".") -(load "ert-buffer" nil t) -(add-to-list 'load-path "..") -(load "rst.el" nil t) +(load "init" nil t) +(init-rst-ert t) (ert-deftest font-lock--asserts () "Check some assertions." diff --git a/docutils/tools/editors/emacs/tests/imenu.el b/docutils/tools/editors/emacs/tests/imenu.el new file mode 100644 index 000000000..e21561b93 --- /dev/null +++ b/docutils/tools/editors/emacs/tests/imenu.el @@ -0,0 +1,111 @@ +;; Tests for rst-imenu-create-index + +(add-to-list 'load-path ".") +(load "init" nil t) +(init-rst-ert t) + +(ert-deftest imenu-asserts () + "Check some assertions." + (should (equal ert-Buf-point-char "\^@")) + (should (equal ert-Buf-mark-char "\^?")) + ) + +(ert-deftest rst-imenu-create-index () + "Tests for `rst-imenu-create-index'." + (should (ert-equal-buffer-return + (rst-imenu-create-index) + " +" + t + nil)) + (should (ert-equal-buffer-return + (rst-imenu-create-index) + " +Some normal text. +" + t + nil)) + (should (ert-equal-buffer-return + (rst-imenu-create-index) + " +Header +======" + t + '(("=Header" . 2)))) + (should (ert-equal-buffer-return + (rst-imenu-create-index) + " +Header +====== + +Subheader +---------" + t + '(("=Header" + ("=Header" . 2) + ("-Subheader" . 17))))) + (should (ert-equal-buffer-return + (rst-imenu-create-index) + " +Header +====== + +Subheader +--------- + +With space +----------" + t + '(("=Header" + ("=Header" . 2) + ("-Subheader" . 17) + ("-With space" . 38))))) + (should (ert-equal-buffer-return + (rst-imenu-create-index) + " +Header +====== + +Subheader +--------- + +With space +---------- + +Top level again +===============" + t + '(("=Header" + ("=Header" . 2) + ("-Subheader" . 17) + ("-With space" . 38)) + ("=Top level again" . 61)))) + (should (ert-equal-buffer-return + (rst-imenu-create-index) + " +Header +====== + +Subheader +--------- + +With space +---------- + +Sub sub +~~~~~~~ + +Top level again +===============" + t + '(("=Header" + ("=Header" . 2) + ("-Subheader" . 17) + ("-With space" + ("-With space" . 38) + ("~Sub sub" . 61))) + ("=Top level again" . 78)))) + ) + +;; FIXME: Test missing intermediate sections. +;; FIXME: Test document titles. diff --git a/docutils/tools/editors/emacs/tests/indent.el b/docutils/tools/editors/emacs/tests/indent.el index dbd2d1da0..18e2ca952 100644 --- a/docutils/tools/editors/emacs/tests/indent.el +++ b/docutils/tools/editors/emacs/tests/indent.el @@ -1,9 +1,8 @@ ;; Tests for functions around indentation (add-to-list 'load-path ".") -(load "ert-buffer" nil t) -(add-to-list 'load-path "..") -(load "rst.el" nil t) +(load "init" nil t) +(init-rst-ert t) (ert-deftest indent-asserts () "Check some assertions." diff --git a/docutils/tools/editors/emacs/tests/init.el b/docutils/tools/editors/emacs/tests/init.el new file mode 100644 index 000000000..caf9a1c42 --- /dev/null +++ b/docutils/tools/editors/emacs/tests/init.el @@ -0,0 +1,31 @@ +;; Initialize tests + +(defun init-rst-ert (&optional with-buffer) + "Initialize tests. +Prepare for buffer using tests if WITH-BUFFER." + (when with-buffer + (add-to-list 'load-path ".") + (load "ert-buffer" nil t) + (if (equal (car load-path) ".") + (setq load-path (cdr load-path)))) + + (add-to-list 'load-path "..") + (load "rst.el" nil t) + (if (equal (car load-path) "..") + (setq load-path (cdr load-path))) + + ;; Emacs 24 should have a patch in `testcover-after` declaring a + ;; `gv-expander'. + (if (< emacs-major-version 24) + ;; Define a setf-method for `testcover-after' so `ert' tests can be run + ;; without problems. + (defsetf testcover-after (idx val) (store) + (list 'progn + (list 'testcover-after idx val) + ;; FIXME: Though it solves the problem it is not really correct + ;; because `val' is only a temporary variable here. + (list 'setf val store))))) + +;; Clean up `load-path' if set caller just to load this file. +(if (equal (car load-path) ".") + (setq load-path (cdr load-path))) diff --git a/docutils/tools/editors/emacs/tests/items.el b/docutils/tools/editors/emacs/tests/items.el index 1c3c7268d..e86af1d43 100644 --- a/docutils/tools/editors/emacs/tests/items.el +++ b/docutils/tools/editors/emacs/tests/items.el @@ -1,9 +1,8 @@ ;; Tests for operations on list items (add-to-list 'load-path ".") -(load "ert-buffer" nil t) -(add-to-list 'load-path "..") -(load "rst.el" nil t) +(load "init" nil t) +(init-rst-ert t) (ert-deftest items-asserts () "Check some assertions." diff --git a/docutils/tools/editors/emacs/tests/movement.el b/docutils/tools/editors/emacs/tests/movement.el index fcfc9ca84..a6d66fef0 100644 --- a/docutils/tools/editors/emacs/tests/movement.el +++ b/docutils/tools/editors/emacs/tests/movement.el @@ -1,9 +1,8 @@ ;; Tests for various movement commands (add-to-list 'load-path ".") -(load "ert-buffer" nil t) -(add-to-list 'load-path "..") -(load "rst.el" nil t) +(load "init" nil t) +(init-rst-ert t) (ert-deftest movement-asserts () "Check some assertions." diff --git a/docutils/tools/editors/emacs/tests/re.el b/docutils/tools/editors/emacs/tests/re.el index df0b0b2b5..979a2b5c9 100644 --- a/docutils/tools/editors/emacs/tests/re.el +++ b/docutils/tools/editors/emacs/tests/re.el @@ -1,9 +1,8 @@ ;; Tests for the regular expression builder (add-to-list 'load-path ".") -(load "ert-buffer" nil t) -(add-to-list 'load-path "..") -(load "rst.el" nil t) +(load "init" nil t) +(init-rst-ert t) (ert-deftest rst-re () "Tests `rst-re'." diff --git a/docutils/tools/editors/emacs/tests/shift.el b/docutils/tools/editors/emacs/tests/shift.el index f966b266a..ea30cf5e0 100644 --- a/docutils/tools/editors/emacs/tests/shift.el +++ b/docutils/tools/editors/emacs/tests/shift.el @@ -1,9 +1,8 @@ ;; Tests for various functions around shifting text (add-to-list 'load-path ".") -(load "ert-buffer" nil t) -(add-to-list 'load-path "..") -(load "rst.el" nil t) +(load "init" nil t) +(init-rst-ert t) (ert-deftest shift-asserts () "Check some assertions." diff --git a/docutils/tools/editors/emacs/tests/toc.el b/docutils/tools/editors/emacs/tests/toc.el index e11d5dbb1..1f53c8d63 100644 --- a/docutils/tools/editors/emacs/tests/toc.el +++ b/docutils/tools/editors/emacs/tests/toc.el @@ -1,9 +1,8 @@ ;; Tests for operations on toc (add-to-list 'load-path ".") -(load "ert-buffer" nil t) -(add-to-list 'load-path "..") -(load "rst.el" nil t) +(load "init" nil t) +(init-rst-ert t) (ert-deftest toc-asserts () "Check some assertions." @@ -151,6 +150,6 @@ Header C ) )) -;; More functions to test: +;; FIXME: More functions to test: ;; * rst-toc ;; * rst-toc-mode-goto-section diff --git a/docutils/tools/editors/emacs/tests/tree.el b/docutils/tools/editors/emacs/tests/tree.el new file mode 100644 index 000000000..5c475430f --- /dev/null +++ b/docutils/tools/editors/emacs/tests/tree.el @@ -0,0 +1,202 @@ +;; Tests for `rst-section-tree' + +(add-to-list 'load-path ".") +(load "init" nil t) +(init-rst-ert t) + +(ert-deftest toc-asserts () + "Check some assertions." + (should (equal ert-Buf-point-char "\^@")) + (should (equal ert-Buf-mark-char "\^?")) + ) + +(defun mrk2int (obj) + "Replace all markers in OBJ by integers and return result." + (cond + ((markerp obj) + (marker-position obj)) + ((stringp obj) + obj) + ((sequencep obj) + (mapcar 'mrk2int obj)) + (t obj))) + +(defun section-tree () + "Return result of `rst-section-tree' with markers replaced by integers." + (mrk2int (rst-section-tree))) + +(defun section-tree-point () + "Return result of `rst-section-tree-point' with markers replaced by integers." + (mrk2int (rst-section-tree-point (rst-section-tree)))) + +(ert-deftest rst-section-tree () + "Tests `rst-section-tree'." + (let ((title "===== +Title +===== + +") + (headers "Header A +======== + +Header B +======== + +Subheader B.a +------------- + +SubSubheader B.a.1 +~~~~~~~~~~~~~~~~~~ + +Subheader B.b +------------- + +Header C +========")) + (should (ert-equal-buffer-return + (section-tree) + "" + t + '((nil)) + )) + (should (ert-equal-buffer-return + (section-tree) + title + t + '((nil 7) (("Title" 7))) + )) + (should (ert-equal-buffer-return + (section-tree) + (concat title headers) + t + '((nil 7) + (("Title" 7) + (("Header A" 20)) + (("Header B" 39) + (("Subheader B.a" 58) + (("SubSubheader B.a.1" 87))) + (("Subheader B.b" 126))) + (("Header C" 155)))) + )) + )) + +(ert-deftest rst-section-tree-point () + "Tests `rst-section-tree-point'." + (let ((title "===== +Title +===== + +")) + (should (ert-equal-buffer-return + (section-tree-point) + "\^@" + t + '(((nil))) + )) + (should (ert-equal-buffer-return + (section-tree-point) + (concat "\^@" title) + t + '(((nil 7))) + )) + (should (ert-equal-buffer-return + (section-tree-point) + (concat title "\^@") + t + '(((nil 7) ("Title" 7)) ("Title" 7)) + )) + (should (ert-equal-buffer-return + (section-tree-point) + (concat title "\^@Header A +======== + +Header B +======== + +Subheader B.a +------------- + +SubSubheader B.a.1 +~~~~~~~~~~~~~~~~~~ + +Subheader B.b +------------- + +Header C +========") + t + '(((nil 7) ("Title" 7) ("Header A" 20)) ("Header A" 20)) + )) + (should (ert-equal-buffer-return + (section-tree-point) + (concat title "Header A +======== + +Header B +======== +\^@ +Subheader B.a +------------- + +SubSubheader B.a.1 +~~~~~~~~~~~~~~~~~~ + +Subheader B.b +------------- + +Header C +========") + t + '(((nil 7) ("Title" 7) ("Header B" 39)) ("Header B" 39) + (("Subheader B.a" 58) + (("SubSubheader B.a.1" 87))) + (("Subheader B.b" 126))) + )) + (should (ert-equal-buffer-return + (section-tree-point) + (concat title "Header A +======== + +Header B +======== + +Subheader B.a\^@ +------------- + +SubSubheader B.a.1 +~~~~~~~~~~~~~~~~~~ + +Subheader B.b +------------- + +Header C +========") + t + '(((nil 7) ("Title" 7) ("Header B" 39) ("Subheader B.a" 58)) + ("Subheader B.a" 58) + (("SubSubheader B.a.1" 87))) + )) + (should (ert-equal-buffer-return + (section-tree-point) + (concat title "Header A +======== + +Header B +======== + +Subheader B.a +------------- + +SubSubheader B.a.1 +~~~~~~~~~~~~~~~~~~ + +S\^@ubheader B.b +------------- + +Header C +========") + t + '(((nil 7) ("Title" 7) ("Header B" 39) ("Subheader B.b" 126)) + ("Subheader B.b" 126)) + )) + )) |
