summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2025-10-26 20:50:53 -0500
committerCraig Jennings <c@cjennings.net>2025-10-26 20:50:53 -0500
commitcaecfc47339c8f6ad0439d0851168655725ae8d8 (patch)
tree2b55cc2833a08abbcff7636bbb2672a7c7a09fb1
parent1066d0410660d1820064c757abe7b5aad6e6070f (diff)
test:removing old (now redundant) tests
-rw-r--r--tests/test-fixup-whitespace.el.disabled159
-rw-r--r--tests/test-flyspell-config-functions.el.disabled149
-rw-r--r--tests/test-format-region.el.disabled110
-rw-r--r--tests/test-theme-theme-persistence.el.disabled135
-rw-r--r--tests/test-title-case-region.el.disabled44
5 files changed, 0 insertions, 597 deletions
diff --git a/tests/test-fixup-whitespace.el.disabled b/tests/test-fixup-whitespace.el.disabled
deleted file mode 100644
index 0126801a..00000000
--- a/tests/test-fixup-whitespace.el.disabled
+++ /dev/null
@@ -1,159 +0,0 @@
-;;; test-fixup-whitespace.el --- -*- lexical-binding: t; -*-
-
-;;; Commentary:
-;; Test cj/fixup-whitespace-line-or-region in custom-functions.el
-
-;; The function under test should:
-;; - ensure there is exactly one space between words
-;; - remove tab characters
-;; - remove leading and trailing whitespace
-;; - operate on a line, or a region, if selected
-
-;;; Code:
-
-
-(require 'ert)
-(add-to-list 'load-path (concat user-emacs-directory "modules"))
-(require 'custom-functions)
-
-(ert-deftest test-cj/fixup-whitespace-positive-first-line-only ()
- "Test a positive case with two lines.
-Both lines have whitespace at the beginning and the end. This tests that when
-this function is called on the first line, only that line is affected."
- (let ((testdata " Hello, world! \n Foo bar ")
- (expected "Hello, world!\n Foo bar ")
- (actual))
- (with-temp-buffer
- (insert testdata)
- (goto-char (point-min))
- (cj/fixup-whitespace-line-or-region)
- (setq actual (buffer-string))
- (should (string= actual expected)))))
-
-(ert-deftest test-cj/fixup-whitespace-positive-first-line-only-tabs ()
- "Test a positive case with two lines.
-Both lines have extraneous whitespace at the beginning and the end, includuing
-tabs. This tests that when this function is called on the first line, only that
-line is affected."
- (let ((testdata " Hello,\t world! \n Foo\tbar ")
- (expected "Hello, world!\n Foo\tbar ")
- (actual))
- (with-temp-buffer
- (insert testdata)
- (goto-char (point-min))
- (cj/fixup-whitespace-line-or-region)
- (setq actual (buffer-string))
- (should (string= actual expected)))))
-
-(ert-deftest test-cj/fixup-whitespace-positive-first-line-only-tabs2 ()
- "Test a positive case with two lines.
-Both lines have extraneous whitespace at the beginning and the end, includuing
-tabs. This tests that when this function is called on the first line, only that
-line is affected."
- (let ((testdata "\t Hello,\tworld! \n Foo\t bar\t ")
- (expected "Hello, world!\n Foo\t bar\t ")
- (actual))
- (with-temp-buffer
- (insert testdata)
- (goto-char (point-min))
- (cj/fixup-whitespace-line-or-region)
- (setq actual (buffer-string))
- (should (string= actual expected)))))
-
-(ert-deftest test-cj/fixup-whitespace-negative-first-line-only ()
- "Test a negative case with two lines.
-Only the second line has whitespace at the beginning and the end. This tests
-that when this function is called on the first line, neither line changes."
- (let ((testdata "Hello, world!\n Foo bar ")
- (expected "Hello, world!\n Foo bar ")
- (actual))
- (with-temp-buffer
- (insert testdata)
- (goto-char (point-min))
- (cj/fixup-whitespace-line-or-region)
- (setq actual (buffer-string))
- (should (string= actual expected)))))
-
-(ert-deftest test-cj/fixup-whitespace-positive-second-line-only ()
- "Test a positive case with two lines.
-Both lines have whitespace at the beginning and the end. This tests that when
-function is called on the second line, only that line is affected."
- (let ((testdata " Hello, world! \n Foo bar ")
- (expected " Hello, world! \nFoo bar")
- (actual))
- (with-temp-buffer
- (insert testdata)
- (goto-char (point-min))
- (forward-line)
- (cj/fixup-whitespace-line-or-region)
- (setq actual (buffer-string))
- (should (string= actual expected)))))
-
-(ert-deftest test-cj/fixup-whitespace-negative-second-line-only ()
- "Test a negative case with two lines.
-Only the first line has whitespace at the beginning and the end. This tests
-that when this function is called on the first line, neither line changes."
- (let ((testdata " Hello, world! \nFoo bar")
- (expected " Hello, world! \nFoo bar")
- (actual))
- (with-temp-buffer
- (insert testdata)
- (goto-char (point-min))
- (forward-line)
- (cj/fixup-whitespace-line-or-region)
- (setq actual (buffer-string))
- (should (string= actual expected)))))
-
-(ert-deftest test-cj/fixup-whitespace-positive-region ()
- "Test a positive case with a region.
-Two lines have whitespace at the beginning, the middle, and the end. This tests
-that when this function is called with a region, all whitespace is cleaned up as
-expected."
- (let ((testdata " Hello, world! \n Foo bar ")
- (expected "Hello, world!\nFoo bar")
- (actual))
- (with-temp-buffer
- (insert testdata)
- (goto-char (point-min))
- (set-mark (point))
- (goto-char (point-max))
- (cj/fixup-whitespace-line-or-region t)
- (setq actual (buffer-string))
- (should (string= actual expected)))))
-
-(ert-deftest test-cj/fixup-whitespace-positive-region-tabs ()
- "Test a positive case with a region and tabs.
-Two lines have extraneous whitespace at the beginning, the middle, and the end.
-This tests that when this function is called with a region, all whitespace is
-cleaned up as expected."
- (let ((testdata " \t \t Hello, world! \n Foo\t bar ")
- (expected "Hello, world!\nFoo bar")
- (actual))
- (with-temp-buffer
- (insert testdata)
- (goto-char (point-min))
- (set-mark (point))
- (goto-char (point-max))
- (cj/fixup-whitespace-line-or-region t)
- (setq actual (buffer-string))
- (should (string= actual expected)))))
-
-(ert-deftest test-cj/fixup-whitespace-negative-region ()
- "Test a negative case with a region.
-Two lines are inserted, neither of which have extraneous whitespace. This tests
-that when this function is called with a region, there's no unwanted
-side-effects and nothing changes."
- (let ((testdata "Hello, world!\nFoo bar")
- (expected "Hello, world!\nFoo bar")
- (actual))
- (with-temp-buffer
- (insert testdata)
- (goto-char (point-min))
- (set-mark (point))
- (goto-char (point-max))
- (cj/fixup-whitespace-line-or-region t)
- (setq actual (buffer-string))
- (should (string= actual expected)))))
-
-(provide 'test-fixup-whitespace)
-;;; test-fixup-whitespace.el ends here.
diff --git a/tests/test-flyspell-config-functions.el.disabled b/tests/test-flyspell-config-functions.el.disabled
deleted file mode 100644
index d12ac167..00000000
--- a/tests/test-flyspell-config-functions.el.disabled
+++ /dev/null
@@ -1,149 +0,0 @@
-;;; test-flyspell-config-functions.el --- -*- lexical-binding: t; -*-
-
-;;; Commentary:
-;; Evaluate the buffer, then run (ert-all-tests).
-
-;;; Code:
-
-(add-to-list 'load-path (concat user-emacs-directory "modules"))
-(require 'flyspell-and-abbrev)
-
-;; --------------------------- Flyspell Overlay Tests --------------------------
-
-(ert-deftest cj/flyspell-overlay-test-positive ()
- "Simplest positive test for \='cj/find-previous-flyspell-overlay\='.
-With one misspelling, cj/find-previous-flyspell-overlay should return the
-character position at the beginning of the misspelled word."
- (with-temp-buffer
- (let ((misspelled "mispeled")
- (overlay-pos))
- ;; insert some text
- (insert (format "some text for testing. %s" misspelled))
-
- ;; trigger flyspell and wait for it to complete
- (flyspell-buffer)
- (sit-for 1)
-
- ;; call the function with position at end of the buffer
- (setq overlay-pos (cj/find-previous-flyspell-overlay (point-max)))
-
- ;; test flyspell-auto-correct-previous-pos is at char position of 'mispeled'.
- (should (eq (- (point-max) (length misspelled)) overlay-pos)))))
-
-(ert-deftest cj/flyspell-overlay-test-negative ()
- "Simplest negative test for \='cj/find-previous-flyspell-overlay\='.
-With no misspelled words, cj/find-previous-flyspell-overlay should return nil."
- (with-temp-buffer
- (insert "This is a correctly spelled sentence.")
- (flyspell-buffer)
- ;; No overlay should exist, so test the result is nil.
- (should-not (cj/find-previous-flyspell-overlay (point-max)))))
-
-(ert-deftest cj/flyspell-overlay-test-positive-multiple ()
- "Positive test for \='cj/find-previous-flyspell-overlay\='.
-With several misspellings above and below, cj/find-previous-flyspell-overlay
-should return the character position at the beginning of the previous misspelled
-word."
- (with-temp-buffer
- (let ((misspelled0 "incorect")
- (misspelled1 "wrongg")
- (misspelled2 "erroor")
- (misspelled3 "mistken")
- (actual-pos)
- (expected-pos)
- (between-pos))
-
- ;; insert some text with misspellings
- (insert (format "flyspell should catch this: %s" misspelled0))
- (insert (format "flyspell should catch this: %s" misspelled1))
-
- ;; calculate the overlay's expected position based on our current position
- (setq expected-pos (- (point) (length misspelled1)))
-
- ;; calculate a position in between misspellings
- (setq between-pos (+ expected-pos (length misspelled1) 5))
-
- ;; insert the rest of the misspellings
- (insert (format "flyspell should catch this: %s" misspelled2))
- (insert (format "flyspell should catch this: %s" misspelled3))
-
- ;; trigger Flyspell and wait for it to identify all misspellings.
- (flyspell-buffer)
- (sit-for 1)
-
- ;; call the function with position in between misspellings
- (setq actual-pos (cj/find-previous-flyspell-overlay between-pos))
- (should (eq expected-pos actual-pos)))))
-
-
-(ert-deftest cj/flyspell-goto-previous-misspelling-positive ()
- "Positive test for \='cj/flyspell-goto-previous-misspelling\='.
-With a simple misspelling above, cj/flyspell-goto-previous-misspelling
-should land on the next misspelled word."
- (with-temp-buffer
- (let ((misspelled-word "incorect")
- (actual-word))
-
- ;; insert some text with misspellings
- (insert (format "flyspell should catch this: %s" misspelled-word))
-
- ;; trigger Flyspell and wait for it to identify all misspellings.
- (flyspell-buffer)
- (sit-for 1)
-
- ;; call the function with position in between misspellings
- (setq actual-word (cj/flyspell-goto-previous-misspelling (point-max)))
- (should (string= misspelled-word actual-word)))))
-
-(ert-deftest cj/flyspell-goto-previous-misspelling-negative ()
- "Negative test for \='cj/flyspell-goto-previous-misspelling\='.
-With no misspellings, cj/flyspell-goto-previous-misspelling return nil."
- (with-temp-buffer
- (let ((expected nil)
- (result))
-
- ;; insert some text with misspellings
- (insert (format "None of these words are misspelled."))
-
- ;; trigger Flyspell and wait for it to identify all misspellings.
- (flyspell-buffer)
- (sit-for 1)
-
- ;; call the function with position in between misspellings
- (setq result (cj/flyspell-goto-previous-misspelling (point-max)))
- (message "result is %s" result)
- (should (eq result expected)))))
-
-(ert-deftest cj/flyspell-goto-previous-misspelling-positive-multiple ()
- "Positive test for \='cj/flyspell-goto-previous-misspelling\='.
-With several misspellings above and below, cj/flyspell-goto-previous-misspelling
-should return the misspelled word just previous to the position of the cursor."
- (with-temp-buffer
- (let ((misspelled0 "incorect")
- (misspelled1 "wrongg")
- (misspelled2 "erroor")
- (misspelled3 "mistken")
- (result)
- (between-pos))
-
- ;; insert some text with misspellings
- (insert (format "flyspell should catch this: %s\n" misspelled0))
- (insert (format "flyspell should catch this: %s\n" misspelled1))
-
- ;; calculate a position in between misspellings
- (setq between-pos (+ (point) (length misspelled1) 5))
-
- ;; insert the rest of the misspellings
- (insert (format "flyspell should catch this: %s\n" misspelled2))
- (insert (format "flyspell should catch this: %s\n" misspelled3))
-
- ;; trigger Flyspell and wait for it to identify all misspellings.
- (flyspell-buffer)
- (sit-for 1)
-
- ;; call the function with position in between misspellings
- (setq result (cj/flyspell-goto-previous-misspelling between-pos))
- (should (string= result misspelled1)))))
-
-(provide 'test-flyspell-config-functions)
-;;; test-flyspell-config-functions.el ends here.
diff --git a/tests/test-format-region.el.disabled b/tests/test-format-region.el.disabled
deleted file mode 100644
index 25d2e52e..00000000
--- a/tests/test-format-region.el.disabled
+++ /dev/null
@@ -1,110 +0,0 @@
-;;; test-format-region.el --- -*- lexical-binding: t; -*-
-
-;;; Commentary:
-;; Some basic tests for the custom function cj/format-region-or-buffer in
-;; custom-functions.el
-
-;;; Code:
-
-(add-to-list 'load-path (concat user-emacs-directory "modules"))
-(require 'custom-functions)
-
-
-;; ----------------------------------- Tests -----------------------------------
-
-(defvar test-format-rob-text-data
- '((" spaces in front\nspaces behind " .
- "spaces in front\nspaces behind")
- ("\t tabs and spaces in front\ntabs and spaces behind\t " .
- "tabs and spaces in front\ntabs and spaces behind")))
-
-(defvar test-format-rob-elisp-data
- '(("(defun existential ()\n(if (eq (+ 3 4) 7)\n(order)\n(chaos)))" .
- "(defun existential ()\n (if (eq (+ 3 4) 7)\n (order)\n (chaos)))")))
-
-
-(ert-deftest test-format-rob-positive-text-region ()
- "Test cj/format-region-or-buffer on a selected region.
-This tests "
- (dolist (data-pair test-format-rob-text-data)
- (let* ((testdata (car data-pair))
- (expected (cdr data-pair))
- (actual))
- (with-temp-buffer
- (insert testdata)
- (goto-char (point-min))
- (set-mark (point))
- (goto-char (point-max))
- (cj/format-region-or-buffer)
- (setq actual (buffer-string))
- (should (string= actual expected))))))
-
-(ert-deftest test-format-rob-positive-text-buffer ()
- "Test cj/format-region-or-buffer on the entire buffer.
-This is the same as testing the region without setting a region in the temp
-buffer."
- (dolist (data-pair test-format-rob-text-data)
- (let* ((testdata (car data-pair))
- (expected (cdr data-pair))
- (actual))
- (with-temp-buffer
- (insert testdata)
- (cj/format-region-or-buffer)
- (setq actual (buffer-string))
- (should (string= actual expected))))))
-
-(ert-deftest test-format-rob-positive-region-text-multiple-paragraphs ()
- "Test cj/format-region-or-buffer on the entire buffer."
- (dolist (data-pair test-format-rob-text-data)
- (let ((testdata (car data-pair))
- (expected1 (cdr data-pair))
- (expected2 (car data-pair))
- (actual1)
- (actual2))
- (with-temp-buffer
- ;; insert data twice with newline char in between
- (insert testdata)
- (insert"\n")
- (insert testdata)
-
- ;; select the first set of data
- (goto-char (point-min))
- (set-mark (point))
- (forward-line 2)
-
- ;; run format and return to top
- (cj/format-region-or-buffer)
- (message "buffer is:\n'%s'" (buffer-string))
-
- ;; assert the first set is formatted
- (goto-char (point-min))
- (setq actual1 (buffer-substring (point-min) (line-end-position 2)))
- (should (string= actual1 expected1))
-
- ;; assert the second set is unformatted
- (goto-char (point-min))
- (setq actual2 (buffer-substring (line-beginning-position 3) (point-max)))
- (should (string= actual2 expected2))))))
-
-(ert-deftest test-format-rob-positive-elisp-region ()
- "Test cj/format-region-or-buffer on a selected region.
-This tests that emacs-lisp specific formatting is applied."
- (ws-butler-mode nil)
- (dolist (data-pair test-format-rob-elisp-data)
- (let* ((testdata (car data-pair))
- (expected (cdr data-pair))
- (actual))
- (with-temp-buffer
- (emacs-lisp-mode)
- (insert testdata)
- (goto-char (point-min))
- (set-mark (point))
- (goto-char (point-max))
- (message "buffer before:\n'%s'" (buffer-string))
- (cj/format-region-or-buffer)
- (message "buffer after:\n'%s'" (buffer-string))
- (setq actual (buffer-string))
- (should (string= actual expected))))))
-
-(provide 'test-format-region)
-;;; test-format-region.el ends here.
diff --git a/tests/test-theme-theme-persistence.el.disabled b/tests/test-theme-theme-persistence.el.disabled
deleted file mode 100644
index e0b2f9e3..00000000
--- a/tests/test-theme-theme-persistence.el.disabled
+++ /dev/null
@@ -1,135 +0,0 @@
-;;; test-theme-theme-persistence.el --- Tests theme persistence mechanism -*- lexical-binding: t; -*-
-
-;;; Commentary:
-;; Unit tests for the persistence of the chosen theme
-
-;;; Code:
-
-(add-to-list 'load-path (concat user-emacs-directory "modules"))
-(require 'ui-theme)
-
-;; ------------------------ Constants / Setup / Teardown -----------------------
-
-(defvar cj/original-theme-name nil)
-(defvar cj/original-newline-setting nil)
-
-(defun cj/test-setup ()
- "Required settings and save state before each test."
-
- ;; save the current theme for restoration
- (setq cj/original-theme-name (symbol-name (car custom-enabled-themes)))
- (setq cj/original-newline-setting mode-require-final-newline)
-
- ;; unload all themes before starting test
- (mapcar #'disable-theme custom-enabled-themes)
-
- ;; no EOF newlines
- (custom-set-variables
- '(require-final-newline nil))
- (setq mode-require-final-newline nil))
-
-(defun cj/test-teardown ()
- "Restore the state before each test."
- ;; restore newline setting
- (setq require-final-newline cj/original-newline-setting)
-
- ;; if there wasn't an original theme, remove all themes
- (if (string= cj/original-theme-name "nil")
- (mapcar #'disable-theme custom-enabled-themes)
- ;; otherwise, restore it
- (load-theme (intern cj/original-theme-name))))
-
-;; ----------------------------------- Tests -----------------------------------
-
-(ert-deftest test-write-file-contents ()
- "Normal Case: Uses function to write a string, reads it back, and compares."
- (cj/test-setup)
- (let ((teststring "testing123")
- (testfilename "test-write-file-contents.txt"))
- ;; call the function
- (should (equal (cj/write-file-contents teststring testfilename)
- 't))
- ;; Read the file and check it's contents
- (should (equal (with-temp-buffer(insert-file-contents testfilename)
- (buffer-string))
- teststring))
- ;; clean up test file
- (delete-file testfilename))
- (cj/test-teardown))
-
-(ert-deftest test-write-file-not-writable ()
- "Test writing to a non-writable file."
- (cl-flet ((file-writeable-p (file) nil))
- (let* ((non-writable-file (make-temp-file "test-non-writable"))
- (should (equal (cj/write-file-contents "cowabunga" non-writable-file) 'nil)))
- (delete-file non-writable-file))))
-
-(ert-deftest test-read-file-contents ()
- "Normal Case: Writes string to file and reads contents using function."
- (cj/test-setup)
- (let ((teststring "testing123")
- (testfilename "test-read-file-contents.txt"))
- ;; write the file
- (with-temp-buffer
- (insert teststring)
- (write-file testfilename))
- ;; call the function
- (should (equal (cj/read-file-contents testfilename)
- teststring))
- ;; clean up test file
- (delete-file testfilename))
- (cj/test-teardown))
-
-(ert-deftest test-read-file-nonexistent ()
- "Test reading from a non-existent file returns nil."
- (cj/test-setup)
- (let* ((filename (concat (number-to-string (random 99999999)) "nonexistent-file.txt"))
- (result (cj/read-file-contents filename)))
- (should (equal result nil)))
- (cj/test-teardown))
-
-(ert-deftest test-get-active-theme ()
- (cj/test-setup)
- "Normal Case: Sets theme, gets theme-name, and compares."
- (let ((expected "wombat"))
- (load-theme (intern expected))
- (should (string= (cj/get-active-theme-name) expected))
- (cj/test-teardown)))
-
-(ert-deftest test-get-active-theme ()
- (cj/test-setup)
- "Normal Case: Sets theme, gets theme-name, and compares."
- (let ((expected "nil"))
- (mapcar #'disable-theme custom-enabled-themes)
- (should (equal (cj/get-active-theme-name) expected))
- (cj/test-teardown)))
-
-(ert-deftest test-save-theme-to-file ()
- "Normal case: sets theme, saves it, reads from file, and compares."
- (cj/test-setup)
- (let ((expected "wombat"))
- (load-theme (intern expected))
- (cj/save-theme-to-file)
- (should (equal (cj/read-file-contents theme-file) expected))
- (cj/test-teardown)))
-
-(ert-deftest test-load-theme-from-file ()
- "Normal case: saves new theme to file, loads it from file, and compares."
- (cj/test-setup)
- (let ((expected "wombat")) ;; the ui theme that test-setup uses.
- (cj/write-file-contents expected theme-file)
- (cj/load-theme-from-file)
- (should (equal expected (cj/get-active-theme-name))))
- (cj/test-teardown))
-
-(ert-deftest test-load-nil-theme ()
- "Corner case: saves 'nil as theme name to file, loads it, and compares to not having a theme."
- (cj/test-setup)
- (let ((expected "nil")) ;; the ui theme that test-setup uses.
- (cj/write-file-contents expected theme-file)
- (cj/load-theme-from-file)
- (should (equal expected (cj/get-active-theme-name))))
- (cj/test-teardown))
-
-(provide 'test-theme-theme-persistence)
-;;; test-theme-theme-persistence.el ends here.
diff --git a/tests/test-title-case-region.el.disabled b/tests/test-title-case-region.el.disabled
deleted file mode 100644
index ffab0c24..00000000
--- a/tests/test-title-case-region.el.disabled
+++ /dev/null
@@ -1,44 +0,0 @@
-;;; test-title-case-region.el --- -*- lexical-binding: t; -*-
-
-;;; Commentary:
-;; Tests for the title-case region function in custom-functions.el
-
-;; Note on Title Case
-;; Title case is a capitalization convention where major words are
-;; capitalized,and most minor words are lowercase. Nouns,verbs (including
-;; linking verbs), adjectives, adverbs,pronouns,and all words of four letters or
-;; more are considered major words. Short (i.e., three letters or fewer)
-;; conjunctions, short prepositions,and all articles are considered minor
-;; words."
-
-;; positive case (single line, all lowercase, no skip words)
-;; positive case (six lines, mixed case, skip words)
-;; negative case (single line, all skip-words)
-;; negative case (a long empty string)
-
-
-;;; Code:
-
-(require 'ert)
-(add-to-list 'load-path (concat user-emacs-directory "modules"))
-(require 'custom-functions)
-
-(ert-deftest test-cj/fixup-whitespace-positive-first-line-only ()
- "Test a positive case with two lines.
-Both lines have whitespace at the beginning and the end. This tests that when
-this function is called on the first line, only that line is affected."
- (let ((testdata " Hello, world! \n Foo bar ")
- (expected "Hello, world!\n Foo bar ")
- (actual))
- (with-temp-buffer
- (insert testdata)
- (goto-char (point-min))
- (cj/fixup-whitespace-line-or-region)
- (setq actual (buffer-string))
- (should (string= actual expected)))))
-
-
-
-
-(provide 'test-title-case-region)
-;;; test-title-case-region.el ends here.