summaryrefslogtreecommitdiff
path: root/tools/editors/emacs/tests
diff options
context:
space:
mode:
authorwiemann <wiemann@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2006-01-09 20:44:25 +0000
committerwiemann <wiemann@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2006-01-09 20:44:25 +0000
commitd77fdfef70e08114f57cbef5d91707df8717ea9f (patch)
tree49444e3486c0c333cb7b33dfa721296c08ee4ece /tools/editors/emacs/tests
parent53cd16ca6ca5f638cbe5956988e88f9339e355cf (diff)
parent3993c4097756e9885bcfbd07cb1cc1e4e95e50e4 (diff)
downloaddocutils-0.4.tar.gz
Release 0.4: tagging released revisiondocutils-0.4
git-svn-id: http://svn.code.sf.net/p/docutils/code/tags/docutils-0.4@4268 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
Diffstat (limited to 'tools/editors/emacs/tests')
-rw-r--r--tools/editors/emacs/tests/Makefile9
-rw-r--r--tools/editors/emacs/tests/README27
-rw-r--r--tools/editors/emacs/tests/tests-adjust-section.el830
-rw-r--r--tools/editors/emacs/tests/tests-basic.el813
-rw-r--r--tools/editors/emacs/tests/tests-runner.el167
5 files changed, 1846 insertions, 0 deletions
diff --git a/tools/editors/emacs/tests/Makefile b/tools/editors/emacs/tests/Makefile
new file mode 100644
index 000000000..ea024e3fd
--- /dev/null
+++ b/tools/editors/emacs/tests/Makefile
@@ -0,0 +1,9 @@
+
+runtests:
+ emacs-21 --batch -l tests-basic.el
+ emacs-21 --batch -l tests-adjust-section.el
+
+runtests-emacs-cvs:
+ emacs --script tests-basic.el
+ emacs --script tests-adjust-section.el
+
diff --git a/tools/editors/emacs/tests/README b/tools/editors/emacs/tests/README
new file mode 100644
index 000000000..a1f4b0e4a
--- /dev/null
+++ b/tools/editors/emacs/tests/README
@@ -0,0 +1,27 @@
+==========================================
+ Tests for automatic section adjustment
+==========================================
+
+:Author: Martin Blais <blais@furius.ca>
+:Date: 2005-09-03
+
+
+Running the tests
+=================
+
+To run the test suite, you can either evaluate the relevant progn from within
+emacs, or you can run them from the command-line like this, e.g.::
+
+ emacs --script tests-basic.el
+
+See the Makefile for more details.
+
+Status
+======
+
+We are planning to write many more tests and eventually to rewrite the
+interactive section adjustment because it contains a few bugs (it nonetheless
+pretty much works well otherwise). Some of those bugs have been added and are
+currently failing if you run the tests.
+
+(See the FIXME statements for where to continue.)
diff --git a/tools/editors/emacs/tests/tests-adjust-section.el b/tools/editors/emacs/tests/tests-adjust-section.el
new file mode 100644
index 000000000..a4d39f2bc
--- /dev/null
+++ b/tools/editors/emacs/tests/tests-adjust-section.el
@@ -0,0 +1,830 @@
+;; Authors: Martin Blais <blais@furius.ca>
+;; Date: $Date: 2005/04/01 23:19:41 $
+;; Copyright: This module has been placed in the public domain.
+;;
+;; Regression tests for rst-adjust-section-title.
+;;
+;; Run this with::
+;;
+;; emacs --script tests-adjust-section.el
+;;
+;; See test-runner.el for documentation on how the format of tests.
+
+
+;; Define tests.
+(setq rst-adjust-decoration-tests
+ '(
+;;------------------------------------------------------------------------------
+(nodec-first-simple-1
+"
+Some Title@
+
+"
+"
+============
+ Some Title
+============
+
+"
+)
+
+;;------------------------------------------------------------------------------
+(nodec-first-simple-2
+"
+Some Title
+@
+"
+"
+============
+ Some Title
+============
+
+"
+)
+
+;;------------------------------------------------------------------------------
+(nodec-first-simple-3
+"
+Some Tit@le
+
+"
+"
+============
+ Some Title
+============
+
+"
+)
+
+;;------------------------------------------------------------------------------
+(nodec-first-simple-4
+"
+@Some Title
+
+"
+"
+============
+ Some Title
+============
+
+")
+
+
+;;------------------------------------------------------------------------------
+(nodec-first-simple-others
+"
+Some Title@
+
+Other Title
+-----------
+
+Other Title2
+~~~~~~~~~~~~
+
+"
+"
+============
+ Some Title
+============
+
+Other Title
+-----------
+
+Other Title2
+~~~~~~~~~~~~
+
+"
+)
+
+
+;;------------------------------------------------------------------------------
+(nodec-first-toggle
+"
+Some Title@
+
+"
+"
+Some Title
+==========
+
+"
+(t))
+
+;;------------------------------------------------------------------------------
+(nodec-first-forced
+"
+ Some Title@
+
+"
+"
+================
+ Some Title
+================
+
+"
+)
+
+;;------------------------------------------------------------------------------
+(nodec-first-forced-2
+"
+ Some Title@
+
+"
+"
+Some Title
+==========
+
+"
+(t))
+
+;;------------------------------------------------------------------------------
+(nodec-simple
+"
+Previous Title
+--------------
+
+Some Title@
+
+"
+"
+Previous Title
+--------------
+
+Some Title
+~~~~~~~~~~
+
+"
+)
+
+;;------------------------------------------------------------------------------
+(nodec-simple-neg
+"
+Previous Title
+--------------
+
+Some Title@
+
+Next Title
+~~~~~~~~~~
+
+"
+"
+Previous Title
+--------------
+
+Some Title
+~~~~~~~~~~
+
+Next Title
+~~~~~~~~~~
+
+"
+)
+
+;;------------------------------------------------------------------------------
+(nodec-simple-toggle
+"
+Previous Title
+--------------
+
+Some Title@
+
+"
+"
+Previous Title
+--------------
+
+~~~~~~~~~~
+Some Title
+~~~~~~~~~~
+
+"
+(t))
+
+;;------------------------------------------------------------------------------
+(nodec-simple-force-toggle
+"
+Previous Title
+--------------
+
+ Some Title@
+
+"
+"
+Previous Title
+--------------
+
+~~~~~~~~~~~~~~
+ Some Title
+~~~~~~~~~~~~~~
+
+"
+(t))
+
+
+;;------------------------------------------------------------------------------
+(nodec-simple-forced
+"
+Previous Title
+--------------
+
+ Some Title@
+
+"
+"
+Previous Title
+--------------
+
+Some Title
+~~~~~~~~~~
+
+"
+)
+
+;;------------------------------------------------------------------------------
+(nodec-neg
+"
+Previous Title
+--------------
+
+Some Title@
+
+Next Title
+~~~~~~~~~~
+"
+"
+Previous Title
+--------------
+
+Some Title
+----------
+
+Next Title
+~~~~~~~~~~
+"
+(-1))
+
+;;------------------------------------------------------------------------------
+(incomplete-simple-1
+"
+Previous Title@
+----------
+"
+"
+Previous Title
+--------------
+
+"
+)
+
+;;------------------------------------------------------------------------------
+(incomplete-simple-2
+"
+Previous Title
+----------@
+"
+"
+Previous Title
+--------------
+
+"
+)
+
+;;------------------------------------------------------------------------------
+(incomplete-simple-3
+"
+Previous Title
+-@
+"
+"
+================
+ Previous Title
+================
+
+"
+)
+
+;;------------------------------------------------------------------------------
+(incomplete-simple-too-long
+"
+Previous Title
+------------------@
+"
+"
+Previous Title
+--------------
+
+"
+)
+
+;;------------------------------------------------------------------------------
+(incomplete-simple-uo
+"
+----------------
+ Previous Title
+----------@
+"
+"
+----------------
+ Previous Title
+----------------
+
+"
+)
+
+;;------------------------------------------------------------------------------
+(incomplete-partial-overline
+"
+----------@
+ Previous Title
+----------------
+"
+"
+----------------
+ Previous Title
+----------------
+
+"
+)
+
+;;------------------------------------------------------------------------------
+(incomplete-both
+"
+----------
+ Previous Title@
+-----
+"
+"
+----------------
+ Previous Title
+----------------
+
+"
+)
+
+;;------------------------------------------------------------------------------
+(incomplete-toggle
+"
+Previous Title
+----------@
+"
+"
+--------------
+Previous Title
+--------------
+
+"
+(t))
+
+;;------------------------------------------------------------------------------
+(incomplete-toggle-2
+"
+----------------
+ Previous Title@
+--------
+"
+"
+Previous Title
+--------------
+
+"
+(t))
+
+;;------------------------------------------------------------------------------
+(incomplete-toggle-overline
+"
+--------@
+ Previous Title
+----------------
+"
+"
+Previous Title
+--------------
+
+"
+(t))
+
+;;------------------------------------------------------------------------------
+(incomplete-top
+"--------@
+ Previous Title
+----------------
+"
+"----------------
+ Previous Title
+----------------
+
+"
+)
+
+;;------------------------------------------------------------------------------
+(incomplete-top-2
+"=======
+Document Title@
+==============
+"
+"==============
+Document Title
+==============
+
+"
+)
+
+;;------------------------------------------------------------------------------
+(complete-simple
+"
+================
+ Document Title
+================
+
+SubTitle
+--------
+
+My Title@
+--------
+
+After Title
+~~~~~~~~~~~
+
+"
+"
+================
+ Document Title
+================
+
+SubTitle
+--------
+
+==========
+ My Title
+==========
+
+After Title
+~~~~~~~~~~~
+
+"
+)
+
+;;------------------------------------------------------------------------------
+(complete-simple-neg
+"
+================
+ Document Title
+================
+
+SubTitle
+--------
+
+My Title@
+--------
+
+After Title
+~~~~~~~~~~~
+
+"
+"
+================
+ Document Title
+================
+
+SubTitle
+--------
+
+My Title
+~~~~~~~~
+
+After Title
+~~~~~~~~~~~
+
+"
+(-1))
+
+;;------------------------------------------------------------------------------
+(complete-simple-suggestion-down
+"
+================
+ Document Title
+================
+
+SubTitle
+========
+
+My Title@
+========
+
+"
+"
+================
+ Document Title
+================
+
+SubTitle
+========
+
+My Title
+--------
+
+"
+(-1))
+
+;;------------------------------------------------------------------------------
+(complete-simple-boundary-down
+"
+================
+ Document Title
+================
+
+SubTitle
+========
+
+My Title@
+--------
+
+"
+"
+================
+ Document Title
+================
+
+SubTitle
+========
+
+==========
+ My Title
+==========
+
+"
+(-1))
+
+;;------------------------------------------------------------------------------
+(complete-simple-suggestion-up
+"
+================
+ Document Title
+================
+
+SubTitle
+========
+
+==========
+ My Title@
+==========
+
+"
+"
+================
+ Document Title
+================
+
+SubTitle
+========
+
+My Title
+--------
+
+"
+)
+
+;;------------------------------------------------------------------------------
+(complete-simple-boundary-up ;; Note: boundary-up does not exist.
+"
+================
+ Document Title
+================
+
+SubTitle
+========
+
+My Title@
+--------
+"
+"
+================
+ Document Title
+================
+
+SubTitle
+========
+
+My Title
+========
+
+"
+)
+
+;;------------------------------------------------------------------------------
+(complete-toggle-1
+"
+SubTitle@
+~~~~~~~~
+
+"
+"
+~~~~~~~~~~
+ SubTitle
+~~~~~~~~~~
+
+"
+(t))
+
+;;------------------------------------------------------------------------------
+(complete-toggle-2
+"
+~~~~~~~~~~
+ SubTitle@
+~~~~~~~~~~
+
+"
+"
+SubTitle
+~~~~~~~~
+
+"
+(t))
+
+;;------------------------------------------------------------------------------
+(at-file-beginning
+"
+Document Title@
+
+"
+"
+================
+ Document Title@
+================
+
+"
+)
+
+
+;;------------------------------------------------------------------------------
+(at-file-ending
+"
+
+Document Title@
+"
+"
+
+================
+ Document Title@
+================
+
+"
+)
+
+;;------------------------------------------------------------------------------
+(at-file-ending-2
+"
+
+Document Title@"
+"
+
+================
+ Document Title@
+================
+"
+)
+
+;;------------------------------------------------------------------------------
+(conjoint
+"
+Document Title
+==============
+Subtitle@
+
+"
+"
+Document Title
+==============
+Subtitle@
+--------
+
+"
+)
+
+;;------------------------------------------------------------------------------
+(same-conjoint-2
+"==============
+Document Title@
+==============
+Subtitle
+========
+
+"
+"Document Title@
+==============
+Subtitle
+========
+
+"
+)
+
+;;------------------------------------------------------------------------------
+(same-conjoint-2b
+"
+==============
+Document Title@
+==============
+Subtitle
+========
+
+"
+"
+Document Title@
+==============
+Subtitle
+========
+
+"
+)
+
+
+;;------------------------------------------------------------------------------
+(same-conjoint-2
+"
+==============
+Document Title
+==============
+===============
+Document Title2@
+===============
+
+"
+"
+==============
+Document Title
+==============
+Document Title2
+===============
+
+"
+)
+
+;; FIXME: todo
+;; ;;------------------------------------------------------------------------------
+;; (cycle-previous-only
+;; "
+;; ==================
+;; Document Title
+;; ==================
+;;
+;; Document Title2
+;; ===============
+;;
+;; =======
+;; Bli@
+;; =======
+;;
+;; Document Title2
+;; ===============
+;;
+;; Document Title3
+;; ---------------
+;;
+;; Document Title4
+;; ~~~~~~~~~~~~~~~
+;;
+;; "
+;; "
+;; ==================
+;; Document Title
+;; ==================
+;;
+;; Document Title2
+;; ===============
+;;
+;; Bli@
+;; ---
+;;
+;; Document Title2
+;; ===============
+;;
+;; Document Title3
+;; ---------------
+;;
+;; Document Title4
+;; ~~~~~~~~~~~~~~~
+;;
+;; "
+;; )
+
+))
+
+
+;; Main program. Evaluate this to run the tests.
+;; (setq debug-on-error t)
+
+;; Import the module from the file in the parent directory directly.
+(add-to-list 'load-path ".")
+(load "tests-runner.el")
+(add-to-list 'load-path "..")
+(load "rst.el")
+
+(progn
+ (regression-test-compare-expect-buffer
+ "Test interactive adjustment of sections."
+ rst-adjust-decoration-tests
+ (lambda ()
+ (call-interactively 'rst-adjust))
+ nil))
+
diff --git a/tools/editors/emacs/tests/tests-basic.el b/tools/editors/emacs/tests/tests-basic.el
new file mode 100644
index 000000000..5f94304ce
--- /dev/null
+++ b/tools/editors/emacs/tests/tests-basic.el
@@ -0,0 +1,813 @@
+;; Authors: Martin Blais <blais@furius.ca>
+;; Date: $Date: 2005/04/01 23:19:41 $
+;; Copyright: This module has been placed in the public domain.
+;;
+;; Regression tests for rst-adjust-section-title.
+;;
+;; Run this with::
+;;
+;; emacs --script tests-adjust-section.el
+;;
+;; See test-runner.el for documentation on how the format of tests.
+
+
+;; Import the module from the file in the parent directory directly.
+(add-to-list 'load-path ".")
+(load "tests-runner.el")
+(add-to-list 'load-path "..")
+(load "rst.el")
+
+;; (setq debug-on-error t)
+
+
+(setq rst-line-homogeneous-p-tests
+ '(
+;;------------------------------------------------------------------------------
+(simple "Blablabla bla@" nil)
+(true "-----------@" ?-)
+(indented " -----------@" ?-)
+(letter "aaaa@aaa" ?a)
+(true2 "uuuuuuuuuuuuuuuuu@" ?u)
+(misleading "--=---------@" nil)
+(notstrip " uuuuuuuuuuuuuuuuu@" ?u)
+(notstrip2 " uuuuuuuuuuuuuuuuu @" ?u)
+(position "-------@----" ?-)
+(one-char "-@" nil)
+))
+
+(progn
+ (regression-test-compare-expect-values
+ "Tests for predicate for one char line."
+ rst-line-homogeneous-p-tests 'rst-line-homogeneous-p nil))
+
+(setq rst-line-homogeneous-nodent-p-tests
+ '(
+;;------------------------------------------------------------------------------
+(simple "Blablabla bla@" nil)
+(true "-----------@" ?-)
+(indented " -----------@" nil)
+(letter "aaaa@aaa" ?a)
+(true2 "uuuuuuuuuuuuuuuuu@" ?u)
+(misleading "--=---------@" nil)
+(notstrip " uuuuuuuuuuuuuuuuu@" nil)
+(notstrip2 " uuuuuuuuuuuuuuuuu @" nil)
+(position "-------@----" ?-)
+(one-char "-@" nil)
+))
+
+(progn
+ (regression-test-compare-expect-values
+ "Tests for predicate for one char line."
+ rst-line-homogeneous-nodent-p-tests 'rst-line-homogeneous-nodent-p nil))
+
+
+
+
+(setq rst-normalize-cursor-position-tests
+ '(
+;;------------------------------------------------------------------------------
+(under
+"
+
+Du bon vin tous les jours.
+@
+"
+"
+
+@Du bon vin tous les jours.
+
+"
+)
+
+;;------------------------------------------------------------------------------
+(over
+"
+@
+Du bon vin tous les jours.
+
+"
+"
+
+@Du bon vin tous les jours.
+
+"
+)
+
+;;------------------------------------------------------------------------------
+(underline
+"
+
+Du bon vin tous les jours.
+------@-----
+"
+"
+
+@Du bon vin tous les jours.
+-----------
+"
+)
+
+;;------------------------------------------------------------------------------
+(overline
+"
+------@-----
+Du bon vin tous les jours.
+
+"
+"
+-----------
+@Du bon vin tous les jours.
+
+"
+)
+
+;;------------------------------------------------------------------------------
+(both
+"
+@-----------
+Du bon vin tous les jours.
+-----------
+
+"
+"
+-----------
+@Du bon vin tous les jours.
+-----------
+
+"
+)
+
+;;------------------------------------------------------------------------------
+(joint
+"
+Du bon vin tous les jours.
+@-----------
+Du bon vin tous les jours.
+-----------
+
+"
+"
+@Du bon vin tous les jours.
+-----------
+Du bon vin tous les jours.
+-----------
+
+"
+)
+
+;;------------------------------------------------------------------------------
+(separator
+"
+
+@-----------
+
+"
+"
+
+@-----------
+
+"
+)
+
+;;------------------------------------------------------------------------------
+(between
+"
+Line 1
+@
+Line 2
+
+"
+"
+@Line 1
+
+Line 2
+
+"
+)
+
+;;------------------------------------------------------------------------------
+(between-2
+"
+=====================================
+ Project Idea: Panorama Stitcher
+====================================
+
+:Author: Martin Blais <blais@furius.ca>
+@
+Another Title
+=============
+"
+"
+=====================================
+ Project Idea: Panorama Stitcher
+====================================
+
+@:Author: Martin Blais <blais@furius.ca>
+
+Another Title
+=============
+"
+)
+
+))
+
+
+(progn
+ (regression-test-compare-expect-buffer
+ "Test preparation of cursor position."
+ rst-normalize-cursor-position-tests 'rst-normalize-cursor-position nil))
+
+
+
+
+
+
+
+(setq rst-get-decoration-tests
+ '(
+;;------------------------------------------------------------------------------
+(nodec-1
+"
+
+@Du bon vin tous les jours
+
+"
+(nil nil 0))
+
+;;------------------------------------------------------------------------------
+(nodec-2
+"
+
+@
+Du bon vin tous les jours
+
+"
+(nil nil 0))
+
+;;------------------------------------------------------------------------------
+(nodec-indent
+"
+
+@ Du bon vin tous les jours
+
+"
+(nil nil 2))
+
+;;------------------------------------------------------------------------------
+(underline
+"
+
+@Du bon vin tous les jours
+=========================
+
+"
+(?= simple 0))
+
+;;------------------------------------------------------------------------------
+(underline-incomplete
+"
+
+@Du bon vin tous les jours
+====================
+
+"
+(?= simple 0))
+
+;;------------------------------------------------------------------------------
+(underline-indent
+"
+
+@ Du bon vin tous les jours
+====================
+
+"
+(?= simple 5))
+
+;;------------------------------------------------------------------------------
+(underline-one-char
+"
+
+@Du bon vin tous les jours
+-
+"
+(nil nil 0))
+
+;;------------------------------------------------------------------------------
+(underline-two-char
+"
+
+@Du bon vin tous les jours
+--
+"
+(?- simple 0))
+
+;;------------------------------------------------------------------------------
+(over-and-under
+"
+~~~~~~~~~~~~~~~~~~~~~~~~~
+@Du bon vin tous les jours
+~~~~~~~~~~~~~~~~~~~~~~~~~
+
+"
+(?~ over-and-under 0))
+
+;;------------------------------------------------------------------------------
+(over-and-under-top
+"~~~~~~~~~~~~~~~~~~~~~~~~~
+@Du bon vin tous les jours
+~~~~~~~~~~~~~~~~~~~~~~~~~
+
+"
+(?~ over-and-under 0))
+
+;;------------------------------------------------------------------------------
+(over-and-under-indent
+"
+~~~~~~~~~~~~~~~~~~~~~~~~~
+@ Du bon vin tous les jours
+~~~~~~~~~~~~~~~~~~~~~~~~~
+
+"
+(?~ over-and-under 3))
+
+;;------------------------------------------------------------------------------
+(over-and-under-incomplete
+"
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+@Du bon vin tous les jours
+~~~~~~~~~~~~~~~~~~~
+
+"
+(?~ over-and-under 0))
+
+;;------------------------------------------------------------------------------
+(over-and-under-different-chars
+"
+---------------------------
+@Du bon vin tous les jours
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+"
+(?~ over-and-under 0))
+
+
+;;------------------------------------------------------------------------------
+(not-beginning
+"
+
+Du bon vin to@us les jours
+=========================
+
+"
+(?= simple 0))
+
+;;------------------------------------------------------------------------------
+(over-over-and-under
+"
+@
+=========================
+Du bon vin tous les jours
+=========================
+"
+(nil nil 0))
+
+;;------------------------------------------------------------------------------
+(joint-1
+"
+=========================
+Du bon vin tous les jours
+=========================
+Du bon vin@
+
+"
+(nil nil 0))
+
+;;------------------------------------------------------------------------------
+(joint-2
+"
+=========================
+Du bon vin tous les jours
+=========================
+Du bon vin@
+----------
+
+"
+(45 simple 0))
+
+;;------------------------------------------------------------------------------
+(joint-3
+"
+=========================
+Du bon vin tous les jours
+=========================
+----------
+Du bon vin@
+----------
+
+"
+(45 over-and-under 0))
+
+;;------------------------------------------------------------------------------
+(joint-4
+"
+=========================
+Du bon vin tous les jours
+=========================
+--------------
+ Du bon vin@
+--------------
+
+"
+(45 over-and-under 2))
+
+;;------------------------------------------------------------------------------
+(indented-1
+"
+
+ Du bon vin tous les jours@
+ =========================
+
+"
+(nil nil 2))
+
+))
+
+
+(progn
+ (regression-test-compare-expect-values
+ "Test getting the decoration."
+ rst-get-decoration-tests 'rst-get-decoration nil))
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+(setq text-1
+"===============================
+ Project Idea: My Document
+===============================
+
+:Author: Martin Blais
+
+Introduction
+============
+
+This is the introduction.
+
+Notes
+-----
+
+Some notes.
+
+Main Points
+===========
+
+Yep.
+
+Super Point
+-----------
+
+~~~~~~~~~~~
+@ Sub Point
+~~~~~~~~~~~
+
+Isn't this fabulous?
+
+Conclusion
+==========
+
+That's it, really.
+
+")
+
+
+(setq text-2
+"
+
+Previous
+--------
+
+Current@
+~~~~~~~
+
+Next
+++++
+
+")
+
+(setq text-3
+"
+
+Previous
+--------
+
+Current@
+~~~~~~~
+
+ Next
+ ++++
+
+")
+
+;; ~~~~~~~~~~~~~~~~~~
+;; Buggy Decoration
+;; ~~~~~~
+;;
+;; ~~~~~~~~~~~~
+;; Decoration
+;;
+;;
+;; ==========
+
+(setq rst-find-all-decorations-tests
+ `(
+ ;;------------------------------------------------------------------------------
+ (basic-1 ,text-1
+ ((2 61 over-and-under 3)
+ (7 61 simple 0)
+ (12 45 simple 0)
+ (17 61 simple 0)
+ (22 45 simple 0)
+ (26 126 over-and-under 1)
+ (31 61 simple 0))
+ )
+
+ (basic-2 ,text-2
+ ((3 45 simple 0)
+ (6 126 simple 0)
+ (9 43 simple 0))
+ )
+
+ (basic-3 ,text-3
+ ((3 45 simple 0)
+ (6 126 simple 0))
+ )
+
+ ))
+
+
+(progn
+ (regression-test-compare-expect-values
+ "Test finding all the decorations in a file."
+ rst-find-all-decorations-tests 'rst-find-all-decorations nil))
+
+
+
+
+(setq rst-get-hierarchy-tests
+ `(
+ ;;------------------------------------------------------------------------------
+ (basic-1 ,text-1
+ ((61 over-and-under 3)
+ (61 simple 0)
+ (45 simple 0)
+ (126 over-and-under 1))
+ )
+ ))
+
+(progn
+ (regression-test-compare-expect-values
+ "Test finding the hierarchy of sections in a file."
+ rst-get-hierarchy-tests 'rst-get-hierarchy nil))
+
+
+
+
+(setq rst-get-hierarchy-ignore-tests
+ `(
+ ;;------------------------------------------------------------------------------
+ (basic-1 ,text-1
+ ((61 over-and-under 3)
+ (61 simple 0)
+ (45 simple 0))
+ )
+ ))
+
+(progn
+ (regression-test-compare-expect-values
+ "Test finding the hierarchy of sections in a file, ignoring lines."
+ rst-get-hierarchy-ignore-tests
+ (lambda () (rst-get-hierarchy nil (line-number-at-pos))) nil))
+
+
+
+
+
+
+
+(setq rst-decoration-complete-p-tests
+ '(
+;;------------------------------------------------------------------------------
+(nodec
+"
+
+@Vaudou
+
+" nil ((?= simple 0)))
+
+;;------------------------------------------------------------------------------
+(complete-simple
+"
+@Vaudou
+======
+" t ((?= simple 0)))
+
+;;------------------------------------------------------------------------------
+(complete-over-and-under
+"
+======
+@Vaudou
+======
+" t ((?= over-and-under 0)))
+
+;;------------------------------------------------------------------------------
+(complete-over-and-under-indent
+"
+==========
+@ Vaudou
+==========
+" t ((?= over-and-under 2)))
+
+;;------------------------------------------------------------------------------
+(incomplete-simple-short
+"
+@Vaudou
+=====
+" nil ((?= simple 0)))
+
+;;------------------------------------------------------------------------------
+(incomplete-simple-long
+"
+@Vaudou
+=======
+" nil ((?= simple 0)))
+
+;;------------------------------------------------------------------------------
+(incomplete-simple-mixed
+"
+@Vaudou
+===-==
+" nil ((?= simple 0)))
+
+;;------------------------------------------------------------------------------
+(incomplete-over-and-under-1
+"
+======
+@Vaudou
+=====
+" nil ((?= over-and-under 0)))
+
+;;------------------------------------------------------------------------------
+(incomplete-over-and-under-2
+"
+=====
+@Vaudou
+======
+" nil ((?= over-and-under 0)))
+
+;;------------------------------------------------------------------------------
+(incomplete-over-and-under-mixed-1
+"
+======
+@Vaudou
+===-==
+" nil ((?= over-and-under 0)))
+
+;;------------------------------------------------------------------------------
+(incomplete-over-and-under-mixed-2
+"
+===-==
+@Vaudou
+======
+" nil ((?= over-and-under 0)))
+
+;;------------------------------------------------------------------------------
+(incomplete-over-only
+"
+======
+@Vaudou
+
+" nil ((?= over-and-under 0)))
+
+;;------------------------------------------------------------------------------
+(incomplete-mixed
+"
+======
+@Vaudou
+------
+" nil ((?= over-and-under 0)))
+
+;;------------------------------------------------------------------------------
+(incomplete-over-and-under-1
+"
+==========
+ @Vaudou
+=========
+" nil ((?= over-and-under 0)))
+
+;;------------------------------------------------------------------------------
+(incomplete-over-and-under-2
+"
+=========
+ @Vaudou
+==========
+" nil ((?= over-and-under 0)))
+
+;;------------------------------------------------------------------------------
+(incomplete-over-and-under-mixed-1
+"
+==========
+ @Vaudou
+===-======
+" nil ((?= over-and-under 0)))
+
+;;------------------------------------------------------------------------------
+(incomplete-over-and-under-mixed-2
+"
+===-======
+ @Vaudou
+==========
+" nil ((?= over-and-under 0)))
+
+;;------------------------------------------------------------------------------
+(incomplete-over-only
+"
+==========
+ @Vaudou
+
+" nil ((?= over-and-under 0)))
+
+;;------------------------------------------------------------------------------
+(incomplete-mixed-2
+"
+==========
+ @Vaudou
+----------
+" nil ((?= over-and-under 0)))
+
+))
+
+(progn
+ (regression-test-compare-expect-values
+ "Tests for completeness predicate."
+ rst-decoration-complete-p-tests 'rst-decoration-complete-p nil))
+
+
+
+
+
+
+
+
+
+
+
+
+
+(setq rst-get-decorations-around-tests
+ '(
+;;------------------------------------------------------------------------------
+(simple
+"
+
+Previous
+--------
+
+@Current
+
+Next
+++++
+
+" ((?- simple 0) (?+ simple 0)))
+
+;;------------------------------------------------------------------------------
+(simple-2
+"
+
+Previous
+--------
+
+Current@
+~~~~~~~
+
+Next
+++++
+
+" ((?- simple 0) (?+ simple 0)))
+
+))
+
+(progn
+ (regression-test-compare-expect-values
+ "Tests getting the decorations around a point."
+ rst-get-decorations-around-tests 'rst-get-decorations-around nil))
+
diff --git a/tools/editors/emacs/tests/tests-runner.el b/tools/editors/emacs/tests/tests-runner.el
new file mode 100644
index 000000000..014093e6d
--- /dev/null
+++ b/tools/editors/emacs/tests/tests-runner.el
@@ -0,0 +1,167 @@
+;; Authors: Martin Blais <blais@furius.ca>
+;; Date: $Date: 2005/04/01 23:19:41 $
+;; Copyright: This module has been placed in the public domain.
+;;
+;; Simple generic test runner for test scripts.
+;;
+;; Run this with::
+;;
+;; emacs --script <file>.el
+;;
+;;
+;; There are mainly two useful functions from this pacakge:
+;;
+;; 1. regression-test-compare-expect-values : used to compare expected output
+;; values from running a function;
+;;
+;; 2. regression-test-compare-expect-buffer : used to compare expected output
+;; buffer contents after running the function.
+;;
+;; regression-test-compare-expect-values test format
+;; -------------------------------------------------
+;;
+;; The tests are a list of tuples, with the following entries:
+;;
+;; - a SYMBOL that uniquely identifies the test.
+;;
+;; - the input buffer CONTENTS to prepare and run the test on. If char @ is
+;; present in the buffer, it is removed and the cursor is placed at that
+;; position before running the tested function.
+;;
+;; - the expected OUTPUT value that the function should return. If the actual
+;; output is different from this, the test will fail.
+;;
+;; - an optional list of INPUT ARGUMENTS that the test function is called with
+;; for this test.
+;;
+;; regression-test-compare-expect-buffer test format
+;; -------------------------------------------------
+;;
+;; - a SYMBOL that uniquely identifies the test.
+;;
+;; - the input buffer CONTENTS to prepare and run the test on. Here too, char @
+;; is present in the buffer, it is removed and the cursor is placed at that
+;; position before running the tested function.
+;;
+;; - the EXPECTED buffer contents after the function has been run.
+;; Additionally, if char @ is present, it is checked that the cursor is
+;; located at that position in the buffer after the function is run (this is
+;; optional).
+;;
+;; - an optional list of PREFIX ARGUMENTS, which indicates to the test program
+;; to set those prefix arguments before running the given function. If there
+;; are multiple prefix args, the function is invoked many times.
+;;
+
+
+(require 'cl)
+
+(defvar regression-point-char "@"
+ "Special character used to mark the position of point in input
+ text and expected text.")
+
+(defun regression-test-loop (suitename testfun testlist fun &optional continue)
+ "Loop over a series of tests in a buffer and run the 'testfun'
+function."
+
+ (message (format "\n\n Test Suite: %s\n\n" suitename))
+
+ (let ((buf (get-buffer-create "regression-tests"))
+ errtxt
+ )
+ (dolist (curtest testlist)
+
+ ;; Print current text.
+ (message (format "========= %s" (prin1-to-string (car curtest))))
+
+ ;; Prepare a buffer with the starting text, and move the cursor where
+ ;; the special character is located.
+ (switch-to-buffer buf)
+ (erase-buffer)
+ (insert (cadr curtest))
+
+ (if (not (search-backward regression-point-char nil t))
+ (error (concat "Error: Badly formed test input, missing "
+ "the cursor position marker.")))
+
+ (delete-char 1)
+
+ (setq errtxt (funcall testfun
+ (car curtest)
+ (caddr curtest)
+ (cadddr curtest)))
+
+ (if errtxt
+ (if continue
+ (progn (message errtxt)
+ (message "(Continuing...)"))
+ (error errtxt)))
+ ))
+ (message "Done."))
+
+
+(defun regression-compare-buffers (testname expected testargs)
+ "Compare the buffer and expected text and return actual
+contents if they do not match."
+
+ ;; Run the section title update command n times.
+ (dolist (x (or testargs (list nil)))
+ (let ((current-prefix-arg x))
+ (funcall fun)))
+
+ ;; Compare the buffer output with the expected text.
+ (let* (;; Get the actual buffer contents.
+ (actual (buffer-string))
+ ;; Get the expected location of point
+ (exppoint (string-match regression-point-char expected))
+
+ (expected-clean (if exppoint
+ (concat (substring expected 0 exppoint)
+ (substring expected (+ 1 exppoint)))
+ expected))
+
+ ;; Adjust position of point vs. string index.
+ (exppoint (and exppoint (+ exppoint 1)))
+
+ )
+
+ (if (not (string= expected-clean actual))
+ ;; Error! Test failed.
+ (format "Error: Test %s failed: \nexpected\n%s\ngot\n%s"
+ testname
+ (prin1-to-string expected-clean)
+ (prin1-to-string actual))
+ (if (and exppoint (not (equal exppoint (point))))
+ ;; Error! Test failed, final position of cursor is not the same.
+ (format "Error: Test %s failed: cursor badly placed." testname))
+ )))
+
+(defun regression-test-compare-expect-buffer
+ (suitename testlist fun &optional continue)
+ "Run the regression tests for the expected buffer contents."
+ (regression-test-loop
+ suitename 'regression-compare-buffers testlist fun continue))
+
+
+(defun regression-compare-values (testname expected testargs)
+ "Compare the buffer and expected text and return actual
+contents if they do not match."
+
+ (let (actual)
+ ;; Run the section title update command n times.
+ (setq actual (apply fun testargs))
+
+ ;; Compare the buffer output with the expected text.
+ (if (not (equal actual expected))
+ ;; Error! Test failed.
+ (format "Error: Test %s failed: expected '%s' got '%s'."
+ testname
+ (prin1-to-string expected)
+ (prin1-to-string actual))
+ )))
+
+(defun regression-test-compare-expect-values
+ (suitename testlist fun &optional continue)
+ "Run the regression tests for expected values comparison."
+ (regression-test-loop
+ suitename 'regression-compare-values testlist fun continue))