emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] scratch/so-long 2967cee 2/2: fixup! Add tests for so-long.


From: Phil
Subject: [Emacs-diffs] scratch/so-long 2967cee 2/2: fixup! Add tests for so-long.el
Date: Thu, 27 Jun 2019 08:18:46 -0400 (EDT)

branch: scratch/so-long
commit 2967cee6dc664f6fca16b1e889aafdd4a20e3aa9
Author: Phil Sainty <address@hidden>
Commit: Phil Sainty <address@hidden>

    fixup! Add tests for so-long.el
    
    * Added missing tests
    * Tidied existing tests
---
 .../so-long-tests/autoload-longlines-mode-tests.el |   8 +-
 .../so-long-tests/autoload-major-mode-tests.el     |   7 +-
 .../so-long-tests/autoload-minor-mode-tests.el     |   8 +-
 test/lisp/so-long-tests/so-long-tests-helpers.el   |  27 ++-
 test/lisp/so-long-tests/so-long-tests.el           | 237 +++++++++++++--------
 5 files changed, 178 insertions(+), 109 deletions(-)

diff --git a/test/lisp/so-long-tests/autoload-longlines-mode-tests.el 
b/test/lisp/so-long-tests/autoload-longlines-mode-tests.el
index d32f99a..5a57e04 100644
--- a/test/lisp/so-long-tests/autoload-longlines-mode-tests.el
+++ b/test/lisp/so-long-tests/autoload-longlines-mode-tests.el
@@ -28,8 +28,8 @@
                                                  default-directory))))
 
 (declare-function so-long-tests-remember "so-long-tests-helpers")
-(declare-function so-long-tests-assert-active "so-long-tests-helpers")
-(declare-function so-long-tests-assert-reverted "so-long-tests-helpers")
+(declare-function so-long-tests-assert-and-revert "so-long-tests-helpers")
+(defvar so-long-action)
 
 ;; We're testing the initial state.  We could alternatively use
 ;; `unload-feature' to revert to that, but this option is simple.
@@ -46,8 +46,6 @@
     (push '(eval . (so-long)) safe-local-variable-values)
     (hack-local-variables)
     (should (eq so-long-action 'longlines-mode))
-    (so-long-tests-assert-active 'longlines-mode)
-    (so-long-revert)
-    (so-long-tests-assert-reverted 'longlines-mode)))
+    (so-long-tests-assert-and-revert 'longlines-mode)))
 
 ;;; autoload-longlines-mode-tests.el ends here
diff --git a/test/lisp/so-long-tests/autoload-major-mode-tests.el 
b/test/lisp/so-long-tests/autoload-major-mode-tests.el
index 1b542b6..d82cb59 100644
--- a/test/lisp/so-long-tests/autoload-major-mode-tests.el
+++ b/test/lisp/so-long-tests/autoload-major-mode-tests.el
@@ -28,8 +28,7 @@
                                                  default-directory))))
 
 (declare-function so-long-tests-remember "so-long-tests-helpers")
-(declare-function so-long-tests-assert-active "so-long-tests-helpers")
-(declare-function so-long-tests-assert-reverted "so-long-tests-helpers")
+(declare-function so-long-tests-assert-and-revert "so-long-tests-helpers")
 
 ;; We're testing the initial state.  We could alternatively use
 ;; `unload-feature' to revert to that, but this option is simple.
@@ -42,8 +41,6 @@
     (so-long-tests-remember)
     (insert "-*- so-long -*-\n")
     (normal-mode)
-    (so-long-tests-assert-active 'so-long-mode)
-    (so-long-revert)
-    (so-long-tests-assert-reverted 'so-long-mode)))
+    (so-long-tests-assert-and-revert 'so-long-mode)))
 
 ;;; autoload-major-mode-tests.el ends here
diff --git a/test/lisp/so-long-tests/autoload-minor-mode-tests.el 
b/test/lisp/so-long-tests/autoload-minor-mode-tests.el
index 5ce2834..67f1903 100644
--- a/test/lisp/so-long-tests/autoload-minor-mode-tests.el
+++ b/test/lisp/so-long-tests/autoload-minor-mode-tests.el
@@ -28,8 +28,8 @@
                                                  default-directory))))
 
 (declare-function so-long-tests-remember "so-long-tests-helpers")
-(declare-function so-long-tests-assert-active "so-long-tests-helpers")
-(declare-function so-long-tests-assert-reverted "so-long-tests-helpers")
+(declare-function so-long-tests-assert-and-revert "so-long-tests-helpers")
+(defvar so-long-action)
 
 ;; We're testing the initial state.  We could alternatively use
 ;; `unload-feature' to revert to that, but this option is simple.
@@ -45,8 +45,6 @@
     (push '(eval . (so-long)) safe-local-variable-values)
     (hack-local-variables)
     (should (eq so-long-action 'so-long-minor-mode))
-    (so-long-tests-assert-active 'so-long-minor-mode)
-    (so-long-revert)
-    (so-long-tests-assert-reverted 'so-long-minor-mode)))
+    (so-long-tests-assert-and-revert 'so-long-minor-mode)))
 
 ;;; autoload-minor-mode-tests.el ends here
diff --git a/test/lisp/so-long-tests/so-long-tests-helpers.el 
b/test/lisp/so-long-tests/so-long-tests-helpers.el
index 88b6799..1a8ba45 100644
--- a/test/lisp/so-long-tests/so-long-tests-helpers.el
+++ b/test/lisp/so-long-tests/so-long-tests-helpers.el
@@ -31,17 +31,16 @@
 (defvar so-long-tests-memory nil
   "Original values of minor modes and variables.")
 
-(defun so-long-tests-assert-active (action &optional ignore-so-long-action)
+(defun so-long-tests-assert-active (action)
   "Assert that ACTION is active."
   (cl-destructuring-bind (_key _label actionfunc revertfunc)
       (assq action so-long-action-alist)
-    (unless ignore-so-long-action
-      (should (eq so-long-action action)))
     (should (eq so-long-function actionfunc))
     (should (eq so-long-revert-function revertfunc))
     (should (eq so-long-enabled t))
     (should (eq so-long--active t))
-    (pcase action
+    ;; pcase fails here in Emacs 24.
+    (cl-case action
       ('so-long-mode
        (should (eq major-mode 'so-long-mode))
        (so-long-tests-assert-overrides))
@@ -51,17 +50,16 @@
       ('longlines-mode
        (should (eq longlines-mode t))))))
 
-(defun so-long-tests-assert-reverted (action &optional ignore-so-long-action)
+(defun so-long-tests-assert-reverted (action)
   "Assert that ACTION has been reverted."
   (cl-destructuring-bind (_key _label actionfunc revertfunc)
       (assq action so-long-action-alist)
-    (unless ignore-so-long-action
-      (should (eq so-long-action action)))
     (should (eq so-long-function actionfunc))
     (should (eq so-long-revert-function revertfunc))
     (should (eq so-long-enabled t))
     (should (eq so-long--active nil))
-    (pcase action
+    ;; pcase fails here in Emacs 24.
+    (cl-case action
       ('so-long-mode
        (should-not (eq major-mode 'so-long-mode))
        (so-long-tests-assert-overrides-reverted))
@@ -71,6 +69,12 @@
       ('longlines-mode
        (should-not (eq longlines-mode t))))))
 
+(defun so-long-tests-assert-and-revert (action)
+  "Assert ACTION, revert it, and then assert the revert."
+  (so-long-tests-assert-active action)
+  (so-long-revert)
+  (so-long-tests-assert-reverted action))
+
 (defun so-long-tests-assert-overrides ()
   "Assert that overridden modes and variables have their expected values."
   (dolist (ovar so-long-variable-overrides)
@@ -87,7 +91,12 @@
       (should (equal (symbol-value (car ovar)) (cdr ovar))))))
 
 (defun so-long-tests-remember ()
-  "Remember the original states of modes and variables."
+  "Remember the original states of modes and variables.
+
+Call this after setting up a buffer in the normal (not so-long)
+state for its major mode, so that after triggering a so-long
+action we can call `so-long-revert' and compare the reverted
+state against this remembered state."
   (setq so-long-tests-memory nil)
   (push (cons 'major-mode major-mode)
         so-long-tests-memory)
diff --git a/test/lisp/so-long-tests/so-long-tests.el 
b/test/lisp/so-long-tests/so-long-tests.el
index f1003cb..b1e0cb9 100644
--- a/test/lisp/so-long-tests/so-long-tests.el
+++ b/test/lisp/so-long-tests/so-long-tests.el
@@ -23,8 +23,11 @@
 ;;; Commentary:
 
 ;; Most of these tests use the shebang #!emacs to get `normal-mode' to
-;; select `emacs-lisp-mode', as using a file-local mode variable might
-;; trigger `so-long-file-local-mode-function'.
+;; select `emacs-lisp-mode', as using a file-local mode variable would
+;; usually trigger `so-long-file-local-mode-function'.  In cases where
+;; we need to `hack-local-variables', we instead set `buffer-file-name'.
+;; (We could consistently use the latter, but the mixture of approaches
+;; means that we're testing more things.)
 
 ;; Running the tests with "make lisp/so-long-tests" is like:
 ;;
@@ -47,12 +50,13 @@
 (declare-function so-long-tests-remember "so-long-tests-helpers")
 (declare-function so-long-tests-assert-active "so-long-tests-helpers")
 (declare-function so-long-tests-assert-reverted "so-long-tests-helpers")
+(declare-function so-long-tests-assert-and-revert "so-long-tests-helpers")
 
 ;; Enable the automated behaviour for all tests.
 (global-so-long-mode 1)
 
 (ert-deftest so-long-tests-threshold-under ()
-  "Under threshold."
+  "Under line length threshold."
   (with-temp-buffer
     (insert "#!emacs\n")
     (insert (make-string (1- so-long-threshold) ?x))
@@ -60,7 +64,7 @@
     (should (eq major-mode 'emacs-lisp-mode))))
 
 (ert-deftest so-long-tests-threshold-at ()
-  "At length threshold."
+  "At line length threshold."
   (with-temp-buffer
     (insert "#!emacs\n")
     (insert (make-string (1- so-long-threshold) ?x))
@@ -68,16 +72,14 @@
     (should (eq major-mode 'emacs-lisp-mode))))
 
 (ert-deftest so-long-tests-threshold-over ()
-  "Over length threshold."
+  "Over line length threshold."
   (with-temp-buffer
     (insert "#!emacs\n")
     (normal-mode)
     (so-long-tests-remember)
     (insert (make-string (1+ so-long-threshold) ?x))
     (normal-mode)
-    (so-long-tests-assert-active 'so-long-mode)
-    (so-long-revert)
-    (so-long-tests-assert-reverted 'so-long-mode)))
+    (so-long-tests-assert-and-revert 'so-long-mode)))
 
 (ert-deftest so-long-tests-skip-comments ()
   "Skip leading shebang, whitespace, and comments."
@@ -147,31 +149,42 @@
       (insert (make-string (1+ so-long-threshold) ?x))
       (let ((so-long-action action))
         (normal-mode)
-        (so-long-tests-assert-active action)
-        (so-long-revert)
-        (so-long-tests-assert-reverted action)))))
+        (so-long-tests-assert-and-revert action)))))
 
 (ert-deftest so-long-tests-command-so-long ()
-  "Test using the `so-long' command."
-  (with-temp-buffer
-    (insert "#!emacs\n")
-    (normal-mode)
-    (so-long-tests-remember)
-    (insert (make-string (1+ so-long-threshold) ?x))
-    (so-long)
-    (so-long-tests-assert-active 'so-long-mode)
-    (so-long-revert)
-    (so-long-tests-assert-reverted 'so-long-mode))
-  (dolist (action (mapcar #'car so-long-action-alist))
+  "Test the `so-long' command."
+  ;; Includes argument of nil, meaning the default `so-long-mode' action.
+  (dolist (action (cons nil (mapcar #'car so-long-action-alist)))
     (with-temp-buffer
       (insert "#!emacs\n")
       (normal-mode)
       (so-long-tests-remember)
       (insert (make-string (1+ so-long-threshold) ?x))
       (so-long action)
-      (so-long-tests-assert-active action t)
-      (so-long-revert)
-      (so-long-tests-assert-reverted action t))))
+      (so-long-tests-assert-and-revert (or action 'so-long-mode)))))
+
+(ert-deftest so-long-tests-so-long-menu-item-replace-action ()
+  "Test using the `so-long-menu-item-replace-action' menu item."
+  (with-temp-buffer
+    ;; Due to (with-selected-window (so-long-menu-click-window) ...)
+    ;; (used by `so-long-menu-item-replace-action'), our temp buffer
+    ;; must be in the selected window.
+    (set-window-buffer nil (current-buffer))
+    (insert "#!emacs\n")
+    (normal-mode)
+    (so-long-tests-remember)
+    (insert (make-string (1+ so-long-threshold) ?x))
+    (let (action)
+      (dolist (item so-long-action-alist)
+        ;; n.b. Any existing action is first reverted.
+        (so-long-menu-item-replace-action item)
+        (setq action (car item))
+        (so-long-tests-assert-active action))
+      ;; After all actions have been used, revert to normal and assert
+      ;; that the most recent action to have been applied is the one
+      ;; we have just reverted.
+      (so-long-menu-item-revert)
+      (so-long-tests-assert-reverted action))))
 
 (ert-deftest so-long-tests-major-mode ()
   "Test calling `so-long-mode' directly."
@@ -180,9 +193,7 @@
     (normal-mode)
     (so-long-tests-remember)
     (so-long-mode)
-    (so-long-tests-assert-active 'so-long-mode)
-    (so-long-revert)
-    (so-long-tests-assert-reverted 'so-long-mode)))
+    (so-long-tests-assert-and-revert 'so-long-mode)))
 
 (ert-deftest so-long-tests-minor-mode ()
   "Test calling `so-long-minor-mode' directly."
@@ -191,12 +202,13 @@
     (normal-mode)
     (so-long-tests-remember)
     (so-long-minor-mode 1)
-    (so-long-tests-assert-active 'so-long-minor-mode t)
+    (so-long-tests-assert-active 'so-long-minor-mode)
     (so-long-minor-mode 0)
-    (so-long-tests-assert-reverted 'so-long-minor-mode t)))
+    (so-long-tests-assert-reverted 'so-long-minor-mode)))
 
 (ert-deftest so-long-tests-target-modes ()
   "Targeted major modes."
+  ;; Test the `so-long-target-modes' user option.
   (with-temp-buffer
     (insert "#!emacs\n")
     (insert (make-string (1+ so-long-threshold) ?x))
@@ -219,6 +231,7 @@
 
 (ert-deftest so-long-tests-predicate ()
   "Custom predicate function."
+  ;; Test the `so-long-predicate' user option.
   (with-temp-buffer
     (insert "#!emacs\n")
     ;; Always false.
@@ -232,45 +245,67 @@
 
 (ert-deftest so-long-tests-file-local-action ()
   "File-local action."
-  (with-temp-buffer
-    (setq buffer-file-name (concat (make-temp-name "so-long-tests-") ".el"))
-    (normal-mode)
-    (so-long-tests-remember)
-    (insert ";; -*- so-long-action:so-long-minor-mode; -*-\n")
-    (put 'so-long-action 'safe-local-variable #'symbolp)
-    (insert (make-string (1+ so-long-threshold) ?x))
-    (normal-mode)
-    (so-long-tests-assert-active 'so-long-minor-mode)
-    (so-long-revert)
-    (so-long-tests-assert-reverted 'so-long-minor-mode)))
+  ;; Test `so-long-action' as a file-local variable.
+  ;; Only valid in Emacs26+. Refer to "Caveats" in the so-long.el Commentary.
+  (unless (version< emacs-version "26")
+    (with-temp-buffer
+      (insert "#!emacs\n")
+      (normal-mode)
+      (so-long-tests-remember))
+    ;; n.b. `run-mode-hooks' *only* runs `hack-local-variables' when there's a
+    ;; (buffer-file-name), so the #!emacs approach is insufficient here.  It's
+    ;; valid for the file-locals to be on the second line after the shebang,
+    ;; but with the *.el filename we no longer need the shebang.
+    (with-temp-buffer
+      (setq buffer-file-name (expand-file-name "so-long-tests-data.el"))
+      (insert ";; -*- so-long-action:so-long-minor-mode; -*-\n")
+      (put 'so-long-action 'safe-local-variable #'symbolp)
+      (insert (make-string (1+ so-long-threshold) ?x))
+      (normal-mode)
+      (so-long-tests-assert-and-revert 'so-long-minor-mode))))
 
 (ert-deftest so-long-tests-file-local-action-eval-so-long ()
   "File-local action and eval:(so-long)."
-  (with-temp-buffer
-    (setq buffer-file-name (concat (make-temp-name "so-long-tests-") ".el"))
-    (normal-mode)
-    (so-long-tests-remember)
-    (insert ";; -*- so-long-action:so-long-minor-mode; eval:(so-long) -*-\n")
-    (put 'so-long-action 'safe-local-variable #'symbolp)
-    (push '(eval . (so-long)) safe-local-variable-values)
-    (normal-mode)
-    (so-long-tests-assert-active 'so-long-minor-mode)
-    (so-long-revert)
-    (so-long-tests-assert-reverted 'so-long-minor-mode)))
+  ;; As per previous test, but using file-local `eval' to call `so-long'.
+  ;; Only valid in Emacs26+. Refer to "Caveats" in the so-long.el Commentary.
+  ;; See also `so-long-tests-file-local-action' above.
+  (unless (version< emacs-version "26")
+    (with-temp-buffer
+      (insert "#!emacs\n")
+      (normal-mode)
+      (so-long-tests-remember))
+    (with-temp-buffer
+      (setq buffer-file-name (concat (make-temp-name "so-long-tests-") ".el"))
+      (insert ";; -*- so-long-action:so-long-minor-mode; eval:(so-long) -*-\n")
+      (put 'so-long-action 'safe-local-variable #'symbolp)
+      (push '(eval . (so-long)) safe-local-variable-values)
+      (normal-mode)
+      (so-long-tests-assert-and-revert 'so-long-minor-mode))))
 
-(defvar so-long-tests-local-mode 'unset)
+(defvar so-long-tests-local-mode 'unset
+  "Set by `so-long-tests-file-local-mode-function'.")
+
+(defun so-long-tests-file-local-mode-function (mode)
+  "A custom value for `so-long-file-local-mode-function'."
+  (setq so-long-tests-local-mode mode))
+
+;; Test `so-long-file-local-mode-function' when the file-local major
+;; mode is `emacs-lisp-mode'.
 
 (defmacro so-long-tests-deftest-file-local-emacs-lisp-mode
-    (sym docstring file-local-spec)
+    (sym docstring prop-line &optional local-vars)
   "Generate tests for using `emacs-lisp-mode' as a file-local mode."
+  (setq prop-line (or prop-line "")
+        local-vars (or local-vars ""))
   `(ert-deftest ,sym ()
      ,docstring
      (let ((orig so-long-file-local-mode-function))
-       ;; Do nothing at all.
+       ;; Do nothing at all when a file-local mode is used.
        (setq-default so-long-file-local-mode-function 'so-long-inhibit)
        (with-temp-buffer
-         (insert ,file-local-spec)
+         (insert ,prop-line)
          (insert (make-string (1+ so-long-threshold) ?x))
+         (insert ,local-vars)
          (normal-mode)
          ;; Remember the `emacs-lisp-mode' state.  The other cases
          ;; will validate the 'reverted' state against this.
@@ -279,28 +314,26 @@
        ;; Downgrade the action from major mode to minor mode.
        (setq-default so-long-file-local-mode-function 'so-long-mode-downgrade)
        (with-temp-buffer
-         (insert ,file-local-spec)
+         (insert ,prop-line)
          (insert (make-string (1+ so-long-threshold) ?x))
+         (insert ,local-vars)
          (normal-mode)
-         (so-long-tests-assert-active 'so-long-minor-mode t)
-         (so-long-revert)
-         (so-long-tests-assert-reverted 'so-long-minor-mode t))
+         (so-long-tests-assert-and-revert 'so-long-minor-mode))
        ;; Do not treat the file-local mode specially.
        (setq-default so-long-file-local-mode-function nil)
        (with-temp-buffer
-         (insert ,file-local-spec)
+         (insert ,prop-line)
          (insert (make-string (1+ so-long-threshold) ?x))
+         (insert ,local-vars)
          (normal-mode)
-         (so-long-tests-assert-active 'so-long-mode)
-         (so-long-revert)
-         (so-long-tests-assert-reverted 'so-long-mode))
+         (so-long-tests-assert-and-revert 'so-long-mode))
        ;; Custom function
        (setq-default so-long-file-local-mode-function
-                     (lambda (mode)
-                       (setq so-long-tests-local-mode mode)))
+                     #'so-long-tests-file-local-mode-function)
        (with-temp-buffer
-         (insert ,file-local-spec)
+         (insert ,prop-line)
          (insert (make-string (1+ so-long-threshold) ?x))
+         (insert ,local-vars)
          (let (so-long-tests-local-mode)
            (normal-mode)
            (should (eq so-long-tests-local-mode 'emacs-lisp-mode))
@@ -318,52 +351,61 @@
   "File-local mode (long form). -*- emacs-lisp -*-"
   ";; -*- mode: emacs-lisp -*-\n")
 
+(so-long-tests-deftest-file-local-emacs-lisp-mode
+  so-long-tests-file-local-emacs-lisp-mode-long-form2
+  "File-local mode (long form). -*- emacs-lisp -*-"
+  nil "\n;; Local Variables:\n;; mode: emacs-lisp\n;; End:\n")
+
+;; Test `so-long-file-local-mode-function' when the file-local major
+;; mode is `so-long-mode'.  In this case we should always end up with
+;; the major mode being `so-long-mode'.
+
 (defmacro so-long-tests-deftest-file-local-so-long-mode
-    (sym docstring file-local-spec)
+    (sym docstring prop-line &optional local-vars)
   "Generate tests for using `so-long-mode' as a file-local mode."
+  (setq prop-line (or prop-line "")
+        local-vars (or local-vars ""))
   `(ert-deftest ,sym ()
      ,docstring
      (let ((orig so-long-file-local-mode-function))
-       ;; Do nothing at all.
+       ;; Do nothing at all when a file-local mode is used.
        (setq-default so-long-file-local-mode-function 'so-long-inhibit)
        (with-temp-buffer
          ;; Remember the new-buffer state.  The other cases will
          ;; validate the 'reverted' state against this.
          (so-long-tests-remember)
-         (insert ,file-local-spec)
+         (insert ,prop-line)
          (insert (make-string (1+ so-long-threshold) ?x))
+         (insert ,local-vars)
          (normal-mode)
-         (should (eq major-mode 'so-long-mode)))
+         (so-long-tests-assert-and-revert 'so-long-mode))
        ;; Downgrade from major mode to minor mode.
        (setq-default so-long-file-local-mode-function 'so-long-mode-downgrade)
        (with-temp-buffer
-         (insert ,file-local-spec)
+         (insert ,prop-line)
          (insert (make-string (1+ so-long-threshold) ?x))
+         (insert ,local-vars)
          (normal-mode)
-         (so-long-tests-assert-active 'so-long-mode)
-         (so-long-revert)
-         (so-long-tests-assert-reverted 'so-long-mode))
+         (so-long-tests-assert-and-revert 'so-long-mode))
        ;; Do not treat the file-local mode specially.
        (setq-default so-long-file-local-mode-function nil)
        (with-temp-buffer
-         (insert ,file-local-spec)
+         (insert ,prop-line)
          (insert (make-string (1+ so-long-threshold) ?x))
+         (insert ,local-vars)
          (normal-mode)
-         (so-long-tests-assert-active 'so-long-mode)
-         (so-long-revert)
-         (so-long-tests-assert-reverted 'so-long-mode))
-       ;; Custom function.  When the file-local mode is `so-long-mode'
-       ;; we do not call `so-long-file-local-mode-function' at all.
+         (so-long-tests-assert-and-revert 'so-long-mode))
+       ;; Custom function.
        (setq-default so-long-file-local-mode-function
-                     (lambda (mode)
-                       (setq so-long-tests-local-mode mode)))
+                     #'so-long-tests-file-local-mode-function)
        (with-temp-buffer
-         (insert ,file-local-spec)
+         (insert ,prop-line)
          (insert (make-string (1+ so-long-threshold) ?x))
+         (insert ,local-vars)
          (let (so-long-tests-local-mode)
            (normal-mode)
-           (should (eq so-long-tests-local-mode nil))
            (should (eq so-long--inhibited t))
+           (should (eq so-long-tests-local-mode 'so-long-mode))
            (so-long-tests-assert-active 'so-long-mode)))
        ;; end
        (setq-default so-long-file-local-mode-function orig))))
@@ -378,4 +420,29 @@
   "File-local mode (long form). -*- mode: so-long -*-"
   ";; -*- mode: so-long -*-\n")
 
+(so-long-tests-deftest-file-local-so-long-mode
+  so-long-tests-file-local-so-long-mode-long-form2
+  "File-local mode (long form). -*- mode: so-long -*-"
+  nil "\n;; Local Variables:\n;; mode: so-long\n;; End:\n")
+
+(ert-deftest so-long-tests-commentary ()
+  "Test the `so-long-commentary' command."
+  (so-long-commentary)
+  (should (string= (buffer-name) "*So Long: Commentary*"))
+  (should (eq major-mode 'outline-mode))
+  (should (eq view-mode t))
+  (should (looking-at "^\\* Introduction$"))
+  (goto-char (point-min))
+  (should (looking-at "^so-long\\.el$"))
+  (should (re-search-forward "^\\* Change Log:$")))
+
+(ert-deftest so-long-tests-customize ()
+  "Test the `so-long-customize' command."
+  (so-long-customize)
+  (should (string= (buffer-name) "*Customize Group: So Long*"))
+  (should (eq major-mode 'Custom-mode)))
+
+;; Page break to prevent the local vars strings above from
+;; being misinterpreted as actual local vars declarations.
+
 ;;; so-long-tests.el ends here



reply via email to

[Prev in Thread] Current Thread [Next in Thread]