branch: elpa/devil
commit fa6eb0a319f103ee1fd949cc9cec57bb97989d40
Author: Philip Kaludercic <[email protected]>
Commit: Susam Pal <[email protected]>
Move tests to separate file using ERT
* devil.el: (devil--assert, devil--tests) Remove.
* devil-tests.el: Create new file.
---
devil-tests.el | 34 ++++++++++++++++++++++++++++++++++
devil.el | 24 ------------------------
2 files changed, 34 insertions(+), 24 deletions(-)
diff --git a/devil-tests.el b/devil-tests.el
new file mode 100644
index 0000000000..22e7071201
--- /dev/null
+++ b/devil-tests.el
@@ -0,0 +1,34 @@
+;;; devil-tests.el --- Tests for devil -*- lexical-binding: t; -*-
+
+;;; Commentary:
+
+;; Unit tests for the internal devil logic. Run these with M-x ert
+;; RET devil- RET.
+
+;;; Code:
+
+(require 'ert)
+(require 'devil)
+
+(ert-deftest devil-invalid-key-p ()
+ "Test if `devil--invalid-key-p' words as expected."
+ (should (devil--invalid-key-p ""))
+ (should (devil--invalid-key-p "C-x-C-f"))
+ (should (devil--invalid-key-p "C-x CC-f"))
+ (should (not (devil--invalid-key-p "C-x C-f")))
+ (should (not (devil--invalid-key-p "C-M-x"))))
+
+(ert-deftest devil-translate ()
+ "Test if `devil-translate' works as expected."
+ (should (string= (devil-translate (vconcat ",")) "C-"))
+ (should (string= (devil-translate (vconcat ",x")) "C-x"))
+ (should (string= (devil-translate (vconcat ",x,")) "C-x C-"))
+ (should (string= (devil-translate (vconcat ",x,f")) "C-x C-f"))
+ (should (string= (devil-translate (vconcat ",,")) ","))
+ (should (string= (devil-translate (vconcat ",,,,")) ", ,"))
+ (should (string= (devil-translate (vconcat ",mx")) "C-M-x"))
+ (should (string= (devil-translate (vconcat ",mmx")) "M-x"))
+ (should (string= (devil-translate (vconcat ",mmm")) "M-m")))
+
+(provide 'devil-tests)
+;;; devil-tests.el ends here
diff --git a/devil.el b/devil.el
index 2a341f57f8..afe1336613 100644
--- a/devil.el
+++ b/devil.el
@@ -387,29 +387,5 @@ this-command: %s; last-command: %s;
last-repeatable-command: %s"
(when devil-logging
(apply #'message (concat "Devil: " format-string) args)))
-(defmacro devil--assert (form)
- "Evaluate FORM and cause error if the result is nil."
- `(unless ,form
- (error "Assertion failed: %s" ',form)))
-
-(defun devil--tests ()
- "Test Devil functions assuming Devil has not been customized."
- (devil--assert (devil--invalid-key-p ""))
- (devil--assert (devil--invalid-key-p "C-x-C-f"))
- (devil--assert (devil--invalid-key-p "C-x CC-f"))
- (devil--assert (not (devil--invalid-key-p "C-x C-f")))
- (devil--assert (not (devil--invalid-key-p "C-M-x")))
- (devil--assert (string= (devil-translate (vconcat ",")) "C-"))
- (devil--assert (string= (devil-translate (vconcat ",x")) "C-x"))
- (devil--assert (string= (devil-translate (vconcat ",x,")) "C-x C-"))
- (devil--assert (string= (devil-translate (vconcat ",x,f")) "C-x C-f"))
- (devil--assert (string= (devil-translate (vconcat ",,")) ","))
- (devil--assert (string= (devil-translate (vconcat ",,,,")) ", ,"))
- (devil--assert (string= (devil-translate (vconcat ",mx")) "C-M-x"))
- (devil--assert (string= (devil-translate (vconcat ",mmx")) "M-x"))
- (devil--assert (string= (devil-translate (vconcat ",mmm")) "M-m"))
- (message "Done"))
-
(provide 'devil)
-
;;; devil.el ends here