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

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

[elpa] master 5dff74a 01/11: Cleanup.


From: Jackson Ray Hamilton
Subject: [elpa] master 5dff74a 01/11: Cleanup.
Date: Sat, 14 Mar 2015 20:21:40 +0000

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

    Cleanup.
---
 benchmark/context-coloring-benchmark.el |    2 +
 scripts/download-dependencies.el        |   18 +++++----
 test/context-coloring-test.el           |   60 +++++++++++++++---------------
 3 files changed, 42 insertions(+), 38 deletions(-)

diff --git a/benchmark/context-coloring-benchmark.el 
b/benchmark/context-coloring-benchmark.el
index 3da8d79..2de5646 100644
--- a/benchmark/context-coloring-benchmark.el
+++ b/benchmark/context-coloring-benchmark.el
@@ -28,8 +28,10 @@
 
 ;;; Code:
 
+(require 'context-coloring)
 (require 'js2-mode)
 
+
 (defconst context-coloring-benchmark-path
   (file-name-directory (or load-file-name buffer-file-name))
   "This file's directory.")
diff --git a/scripts/download-dependencies.el b/scripts/download-dependencies.el
index 54211cc..b4a82fc 100644
--- a/scripts/download-dependencies.el
+++ b/scripts/download-dependencies.el
@@ -22,31 +22,33 @@
 
 ;;; Code:
 
-(defconst directory (file-name-directory (or load-file-name buffer-file-name))
+(defconst download-dependencies-directory
+  (file-name-directory (or load-file-name buffer-file-name))
   "This file's directory.")
 
-(defun resolve-path (path)
+(defun download-dependencies-resolve-path (path)
   "Resolve a path relative to this file's directory."
-  (expand-file-name path directory))
+  (expand-file-name path download-dependencies-directory))
 
-(defun strip-headers ()
+(defun download-dependencies-strip-headers ()
   "Remove the http headers included in the output of
 `url-retrieve-synchronously'."
   (goto-char 1)
-  (kill-paragraph 1) ; The headers are 1 paragraph. I hope.
+  (kill-paragraph 1) ; The headers are 1 paragraph.  I hope.
   (kill-line)        ; A line separates the headers from the file's content.
   )
 
 ;; Download any missing dependencies.
 (let ((files 
'("https://raw.githubusercontent.com/mooz/js2-mode/master/js2-mode.el";
                
"https://raw.githubusercontent.com/rejeep/ert-async.el/master/ert-async.el";)))
-  (make-directory (resolve-path "../libraries") t)
+  (make-directory (download-dependencies-resolve-path "../libraries") t)
   (dolist (file files)
     (let* ((basename (file-name-nondirectory file))
-           (destination (resolve-path (concat "../libraries/" basename))))
+           (destination (download-dependencies-resolve-path
+                         (concat "../libraries/" basename))))
       (when (null (file-exists-p destination))
         (with-current-buffer (url-retrieve-synchronously file)
-          (strip-headers)
+          (download-dependencies-strip-headers)
           (write-file destination))))))
 
 ;;; download-dependencies.el ends here
diff --git a/test/context-coloring-test.el b/test/context-coloring-test.el
index 88a7158..8e26991 100644
--- a/test/context-coloring-test.el
+++ b/test/context-coloring-test.el
@@ -28,7 +28,9 @@
 
 ;;; Code:
 
+(require 'context-coloring)
 (require 'ert-async)
+(require 'js2-mode)
 
 
 ;;; Test running utilities
@@ -50,7 +52,6 @@
 (defun context-coloring-test-cleanup ()
   "Cleanup after all tests."
   (setq context-coloring-comments-and-strings t)
-  (setq context-coloring-after-colorize-hook nil)
   (setq context-coloring-js-block-scopes nil))
 
 (defmacro context-coloring-test-with-fixture (fixture &rest body)
@@ -68,16 +69,15 @@ buffer."
   "Create a temporary buffer, and evaluate CALLBACK there.  A
 teardown callback is passed to CALLBACK for it to invoke when it
 is done."
-  (let ((temp-buffer (make-symbol "temp-buffer")))
-    (let ((previous-buffer (current-buffer))
-          (temp-buffer (generate-new-buffer " *temp*")))
-      (set-buffer temp-buffer)
-      (funcall
-       callback
-       (lambda ()
-         (and (buffer-name temp-buffer)
-              (kill-buffer temp-buffer))
-         (set-buffer previous-buffer))))))
+  (let ((previous-buffer (current-buffer))
+        (temp-buffer (generate-new-buffer " *temp*")))
+    (set-buffer temp-buffer)
+    (funcall
+     callback
+     (lambda ()
+       (and (buffer-name temp-buffer)
+            (kill-buffer temp-buffer))
+       (set-buffer previous-buffer)))))
 
 (defun context-coloring-test-with-fixture-async
     (fixture callback &optional setup)
@@ -163,8 +163,7 @@ Provides the free variables `i', `length', `point', `face' 
and
          (length (- end start)))
      (while (< i length)
        (let* ((point (+ i start))
-              (face (get-text-property point 'face))
-              actual-level)
+              (face (get-text-property point 'face)))
          ,@body)
        (setq i (+ i 1)))))
 
@@ -172,23 +171,24 @@ Provides the free variables `i', `length', `point', 
`face' and
   "Assert that all points in the range [START, END) are of level
 LEVEL."
   (context-coloring-test-assert-region
-   (when (not (when face
-                (let* ((face-string (symbol-name face))
-                       (matches (string-match
-                                 context-coloring-level-face-regexp
-                                 face-string)))
-                  (when matches
-                    (setq actual-level (string-to-number
-                                        (substring face-string
-                                                   (match-beginning 1)
-                                                   (match-end 1))))
-                    (= level actual-level)))))
-     (ert-fail (format (concat "Expected level in region [%s, %s), "
-                               "which is \"%s\", to be %s; "
-                               "but at point %s, it was %s")
-                       start end
-                       (buffer-substring-no-properties start end) level
-                       point actual-level)))))
+   (let (actual-level)
+     (when (not (when face
+                  (let* ((face-string (symbol-name face))
+                         (matches (string-match
+                                   context-coloring-level-face-regexp
+                                   face-string)))
+                    (when matches
+                      (setq actual-level (string-to-number
+                                          (substring face-string
+                                                     (match-beginning 1)
+                                                     (match-end 1))))
+                      (= level actual-level)))))
+       (ert-fail (format (concat "Expected level in region [%s, %s), "
+                                 "which is \"%s\", to be %s; "
+                                 "but at point %s, it was %s")
+                         start end
+                         (buffer-substring-no-properties start end) level
+                         point actual-level))))))
 
 (defun context-coloring-test-assert-region-face (start end expected-face)
   "Assert that all points in the range [START, END) have the face



reply via email to

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