emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] master b468d1c 166/271: Improve block scope test. Rename and docu


From: Jackson Ray Hamilton
Subject: [elpa] master b468d1c 166/271: Improve block scope test. Rename and document block scope variable.
Date: Thu, 05 Feb 2015 18:30:52 +0000

branch: master
commit b468d1c4f3fe1d52949d20510d4227fb5774d305
Author: Jackson Ray Hamilton <address@hidden>
Commit: Jackson Ray Hamilton <address@hidden>

    Improve block scope test. Rename and document block scope variable.
---
 context-coloring.el           |   13 ++++++++-----
 test/context-coloring-test.el |   16 +++++++++++++---
 test/fixtures/block-scopes.js |    7 ++++++-
 3 files changed, 27 insertions(+), 9 deletions(-)

diff --git a/context-coloring.el b/context-coloring.el
index f189473..5818d74 100644
--- a/context-coloring.el
+++ b/context-coloring.el
@@ -53,15 +53,18 @@
 (defcustom context-coloring-delay 0.25
   "Delay between a buffer update and colorization.
 
-Increase this if your machine is high-performing. Decrease it if it ain't."
+Increase this if your machine is high-performing. Decrease it if it ain't.
+
+Supported modes: `js-mode', `js3-mode'"
   :group 'context-coloring)
 
-(defcustom context-coloring-block-scopes nil
+(defcustom context-coloring-js-block-scopes nil
   "If non-nil, add block scopes to the scope hierarchy.
 
 The block-scope-inducing `let' and `const' are introduced in
-ES6. If you are writing ES6 code, then turn this on; otherwise,
-confusion will ensue."
+ES6. If you are writing ES6 code, enable this; otherwise, don't.
+
+Supported modes: `js2-mode'"
   :group 'context-coloring)
 
 
@@ -221,7 +224,7 @@ For example: \"context-coloring-level-1-face\"."
     (while (and scope
                 (js2-node-parent scope)
                 (setq enclosing-scope (js2-node-get-enclosing-scope scope)))
-      (when (or context-coloring-block-scopes
+      (when (or context-coloring-js-block-scopes
                 (let ((type (js2-scope-type scope)))
                   (or (= type js2-SCRIPT)
                       (= type js2-FUNCTION)
diff --git a/test/context-coloring-test.el b/test/context-coloring-test.el
index 1228c44..bb55bc1 100644
--- a/test/context-coloring-test.el
+++ b/test/context-coloring-test.el
@@ -16,8 +16,12 @@
   "Evaluate BODY in a temporary buffer with the relative
 FIXTURE."
   `(with-temp-buffer
-     (insert (context-coloring-test-read-file ,fixture))
-     ,@body))
+     (unwind-protect
+         (progn
+           (insert (context-coloring-test-read-file ,fixture))
+           ,@body)
+       ;; Cleanup.
+       (setq context-coloring-js-block-scopes nil))))
 
 (defmacro context-coloring-test-js-mode (fixture &rest body)
   `(context-coloring-test-with-fixture
@@ -95,7 +99,13 @@ FIXTURE."
 (ert-deftest context-coloring-test-js2-mode-block-scopes ()
   (context-coloring-test-js2-mode
    "./fixtures/block-scopes.js"
-   (context-coloring-test-region-level-p 1 10 0)))
+   (context-coloring-test-region-level-p 20 64 1)
+   (setq context-coloring-js-block-scopes t)
+   (context-coloring-colorize)
+   (context-coloring-test-region-level-p 20 27 1)
+   (context-coloring-test-region-level-p 27 41 2)
+   (context-coloring-test-region-level-p 41 42 1)
+   (context-coloring-test-region-level-p 42 64 2)))
 
 (ert-deftest context-coloring-test-js2-mode-catch ()
   (context-coloring-test-js2-mode
diff --git a/test/fixtures/block-scopes.js b/test/fixtures/block-scopes.js
index cb0c6db..735ca6f 100644
--- a/test/fixtures/block-scopes.js
+++ b/test/fixtures/block-scopes.js
@@ -1 +1,6 @@
-if (1) {}
+(function () {
+    if (1) {
+        var a;
+        let b;
+    }
+}());



reply via email to

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