]> code.delx.au - gnu-emacs-elpa/blobdiff - packages/context-coloring/test/context-coloring-test.el
Merge commit '901db7732bf61d9809712e8adfad9f84adc2eb56' from context-coloring
[gnu-emacs-elpa] / packages / context-coloring / test / context-coloring-test.el
index 903da6824837c7370a227b4db1424717199ccdb0..cbd2002465fdc357e4ebf0f324c9fd132d62845d 100644 (file)
@@ -54,7 +54,8 @@
   (setq context-coloring-comments-and-strings t)
   (setq context-coloring-syntactic-comments nil)
   (setq context-coloring-syntactic-strings nil)
-  (setq context-coloring-js-block-scopes nil))
+  (setq context-coloring-js-block-scopes nil)
+  (setq context-coloring-check-scopifier-version-hook nil))
 
 (defmacro context-coloring-test-with-fixture (fixture &rest body)
   "With the relative FIXTURE, evaluate BODY in a temporary
@@ -136,7 +137,8 @@ in the typical format."
         (function-name (intern-soft
                         (format "context-coloring-test-js-%s" name)))
         (setup-function-name (intern-soft
-                              (format "context-coloring-test-js-%s-setup" name))))
+                              (format
+                               "context-coloring-test-js-%s-setup" name))))
     `(ert-deftest-async ,test-name (done)
                         (context-coloring-test-js-mode
                          ,fixture
@@ -156,7 +158,8 @@ format."
         (function-name (intern-soft
                         (format "context-coloring-test-js-%s" name)))
         (setup-function-name (intern-soft
-                              (format "context-coloring-test-js-%s-setup" name))))
+                              (format
+                               "context-coloring-test-js-%s-setup" name))))
     `(ert-deftest ,test-name ()
        (context-coloring-test-js2-mode
         ,fixture
@@ -287,7 +290,8 @@ is FOREGROUND, or the inverse if NEGATE is non-nil."
                                 "but it %s.")
                         level
                         (if negate "not " "") foreground
-                        (if negate "did" (format "was `%s'" actual-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'
@@ -307,6 +311,38 @@ FOREGROUND.  Apply ARGUMENTS to
     "Context coloring is not available for this major mode"
     "*Messages*")))
 
+(define-derived-mode
+  context-coloring-test-unsupported-version-mode
+  fundamental-mode
+  "Testing"
+  "Prevent `context-coloring-test-unsupported-version' from
+  having any unintentional side-effects on mode support.")
+
+(ert-deftest-async context-coloring-test-unsupported-version (done)
+  (context-coloring-define-dispatch
+   'outta-date
+   :modes '(context-coloring-test-unsupported-version-mode)
+   :executable "node"
+   :command "node test/binaries/outta-date"
+   :version "v2.1.3")
+  (context-coloring-test-with-fixture-async
+   "./fixtures/function-scopes.js"
+   (lambda (teardown)
+     (context-coloring-test-unsupported-version-mode)
+     (add-hook
+      'context-coloring-check-scopifier-version-hook
+      (lambda ()
+        (unwind-protect
+            (progn
+              ;; Normally the executable would be something like "outta-date"
+              ;; rather than "node".
+              (context-coloring-test-assert-message
+               "Update to the minimum version of \"node\" (v2.1.3)"
+               "*Messages*"))
+          (funcall teardown))
+        (funcall done)))
+     (context-coloring-mode))))
+
 (defvar context-coloring-test-theme-index 0
   "Unique index for unique theme names.")