[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 9d55bd6 18/31: Generalize assertions. Write failing test f
From: |
Jackson Ray Hamilton |
Subject: |
[elpa] master 9d55bd6 18/31: Generalize assertions. Write failing test for disabling. |
Date: |
Mon, 09 Feb 2015 01:09:35 +0000 |
branch: master
commit 9d55bd60b5b6b454a75dc6365c2c24f7618b86b8
Author: Jackson Ray Hamilton <address@hidden>
Commit: Jackson Ray Hamilton <address@hidden>
Generalize assertions. Write failing test for disabling.
---
test/context-coloring-test.el | 97 ++++++++++++++++++++++++++++++++--------
1 files changed, 77 insertions(+), 20 deletions(-)
diff --git a/test/context-coloring-test.el b/test/context-coloring-test.el
index a24a60b..dcad8e3 100644
--- a/test/context-coloring-test.el
+++ b/test/context-coloring-test.el
@@ -249,21 +249,31 @@ EXPECTED-FACE."
"Kill BUFFER if it exists."
(if (get-buffer buffer) (kill-buffer buffer)))
-(defun context-coloring-test-assert-face (level foreground)
+(defun context-coloring-test-assert-face (level foreground &optional negate)
"Assert that a face for LEVEL exists and that its `:foreground'
is FOREGROUND."
(let* ((face (context-coloring-face-symbol level))
actual-foreground)
- (when (not face)
+ (when (not (or negate
+ face))
(ert-fail (format (concat "Expected face for level `%s' to exist; "
"but it didn't")
level)))
(setq actual-foreground (face-attribute face :foreground))
- (when (not (string-equal foreground actual-foreground))
+ (when (funcall (if negate 'identity 'not)
+ (string-equal foreground actual-foreground))
(ert-fail (format (concat "Expected face for level `%s' "
- "to have foreground `%s'; but it was `%s'")
+ "%sto have foreground `%s'; "
+ "but it %s.")
level
- foreground actual-foreground)))))
+ (if negate "not " "") foreground
+ (if negate "did" (format "was `%s'"
actual-foreground)))))))
+
+(defun context-coloring-test-assert-not-face (&rest arguments)
+ "Assert that LEVEL does not have a face with `:foreground'
+FOREGROUND."
+ (apply 'context-coloring-test-assert-face
+ (append arguments '(t))))
;;; The tests
@@ -348,33 +358,42 @@ return t for a theme with SETTINGS."
'((theme-face face)))
)
-(defun context-coloring-test-assert-theme-highest-level (settings
expected-level)
- (let (theme)
+(defun context-coloring-test-assert-theme-settings-highest-level
+ (settings expected-level)
+ (let ((theme (context-coloring-test-get-next-theme)))
(put theme 'theme-settings settings)
- (let ((highest-level (context-coloring-theme-highest-level theme)))
- (when (not (eq highest-level expected-level))
- (ert-fail (format (concat "Expected theme with settings `%s' "
- "to have a highest level of `%s', "
- "but it was %s.")
- settings
- expected-level
- highest-level))))))
+ (context-coloring-test-assert-theme-highest-level theme expected-level)))
+
+(defun context-coloring-test-assert-theme-highest-level
+ (theme expected-level &optional negate)
+ (let ((highest-level (context-coloring-theme-highest-level theme)))
+ (when (funcall (if negate 'identity 'not) (eq highest-level
expected-level))
+ (ert-fail (format (concat "Expected theme with settings `%s' "
+ "%sto have a highest level of `%s', "
+ "but it %s.")
+ (get theme 'theme-settings)
+ (if negate "not " "") expected-level
+ (if negate "did" (format "was %s" highest-level)))))))
+
+(defun context-coloring-test-assert-theme-not-highest-level (&rest arguments)
+ (apply 'context-coloring-test-assert-theme-highest-level
+ (append arguments '(t))))
(ert-deftest context-coloring-test-theme-highest-level ()
- (context-coloring-test-assert-theme-highest-level
+ (context-coloring-test-assert-theme-settings-highest-level
'((theme-face foo))
-1)
- (context-coloring-test-assert-theme-highest-level
+ (context-coloring-test-assert-theme-settings-highest-level
'((theme-face context-coloring-level-0-face))
0)
- (context-coloring-test-assert-theme-highest-level
+ (context-coloring-test-assert-theme-settings-highest-level
'((theme-face context-coloring-level-1-face))
1)
- (context-coloring-test-assert-theme-highest-level
+ (context-coloring-test-assert-theme-settings-highest-level
'((theme-face context-coloring-level-1-face)
(theme-face context-coloring-level-0-face))
1)
- (context-coloring-test-assert-theme-highest-level
+ (context-coloring-test-assert-theme-settings-highest-level
'((theme-face context-coloring-level-0-face)
(theme-face context-coloring-level-1-face))
1)
@@ -534,6 +553,44 @@ return t for a theme with SETTINGS."
(context-coloring-test-assert-face 0 "#aaaaaa")
(context-coloring-test-assert-face 1 "#bbbbbb"))
+(defun context-coloring-test-assert-face-count (count &optional negate)
+ (when (funcall (if negate 'identity 'not)
+ (eq context-coloring-face-count count))
+ (ert-fail (format (concat "Expected `context-coloring-face-count' "
+ "%sto be `%s', "
+ "but it %s.")
+ (if negate "not " "") count
+ (if negate
+ "was"
+ (format "was `%s'" context-coloring-face-count))))))
+
+(defun context-coloring-test-assert-not-face-count (&rest arguments)
+ (apply 'context-coloring-test-assert-face-count
+ (append arguments '(t))))
+
+(context-coloring-test-deftest-define-theme disable
+ (context-coloring-test-deftheme theme)
+ (context-coloring-define-theme
+ theme
+ :colors '("#aaaaaa"
+ "#bbbbbb"))
+ (let ((other-theme (context-coloring-test-get-next-theme)))
+ (context-coloring-test-deftheme other-theme)
+ (context-coloring-define-theme
+ other-theme
+ :colors '("#cccccc"
+ "#dddddd"))
+ (enable-theme theme)
+ (enable-theme other-theme)
+ (disable-theme other-theme)
+ (context-coloring-test-assert-face 0 "#aaaaaa")
+ (context-coloring-test-assert-face 1 "#bbbbbb")
+ (context-coloring-test-assert-face-count 2))
+ (disable-theme theme)
+ (context-coloring-test-assert-not-face 0 "#aaaaaa")
+ (context-coloring-test-assert-not-face 1 "#bbbbbb")
+ (context-coloring-test-assert-not-face-count 2))
+
(defun context-coloring-test-js-function-scopes ()
(context-coloring-test-assert-region-level 1 9 0)
(context-coloring-test-assert-region-level 9 23 1)
- [elpa] master 0f036c9 13/31: Improve documentation for themes., (continued)
- [elpa] master 0f036c9 13/31: Improve documentation for themes., Jackson Ray Hamilton, 2015/02/08
- [elpa] master ca7122c 16/31: Remove `when'., Jackson Ray Hamilton, 2015/02/08
- [elpa] master 71a1a0c 14/31: Rename ambiguous "defined" to "originally set"., Jackson Ray Hamilton, 2015/02/08
- [elpa] master c4459fe 02/31: Fix faces on light tty backgrounds. Be more conservative about applying themes., Jackson Ray Hamilton, 2015/02/08
- [elpa] master cda491a 17/31: Long lines., Jackson Ray Hamilton, 2015/02/08
- [elpa] master 807f484 03/31: Allow themes to be overridden, but warn., Jackson Ray Hamilton, 2015/02/08
- [elpa] master 2090e5d 11/31: Add missing case for a theme that does not set faces., Jackson Ray Hamilton, 2015/02/08
- [elpa] master 6eef78b 21/31: Add spacegray theme., Jackson Ray Hamilton, 2015/02/08
- [elpa] master 2b687ae 19/31: Pass test for disabling., Jackson Ray Hamilton, 2015/02/08
- [elpa] master a197a8c 20/31: Add disclaimer about precedence., Jackson Ray Hamilton, 2015/02/08
- [elpa] master 9d55bd6 18/31: Generalize assertions. Write failing test for disabling.,
Jackson Ray Hamilton <=
- [elpa] master 3bd7e26 22/31: Add anti-zenburn theme., Jackson Ray Hamilton, 2015/02/08
- [elpa] master 35b3e71 23/31: Add ample theme., Jackson Ray Hamilton, 2015/02/08
- [elpa] master 0b42ae1 24/31: Add grandshell theme., Jackson Ray Hamilton, 2015/02/08
- [elpa] master 0b8d03d 25/31: Update readme., Jackson Ray Hamilton, 2015/02/08
- [elpa] master fb14816 26/31: Update readme., Jackson Ray Hamilton, 2015/02/08
- [elpa] master c2b6999 29/31: Version 5.0.0., Jackson Ray Hamilton, 2015/02/08
- [elpa] master 6f3ad75 30/31: Update test function documentation., Jackson Ray Hamilton, 2015/02/08
- [elpa] master 2889b27 27/31: Mark unused lexical argument., Jackson Ray Hamilton, 2015/02/08
- [elpa] master 352a8b0 28/31: Delete deprecated function., Jackson Ray Hamilton, 2015/02/08
- [elpa] master f664821 31/31: Merge commit '6f3ad757155b9b3089aba55ee6102ecc9bed647d' from context-coloring, Jackson Ray Hamilton, 2015/02/08