branch: master commit f7f4fe8bb08280201a8e0ce157332702087a61b6 Author: Jackson Ray Hamilton <jack...@jacksonrayhamilton.com> Commit: Jackson Ray Hamilton <jack...@jacksonrayhamilton.com>
Improve elisp tests. --- test/context-coloring-test.el | 32 +++++++++++++++++++++++++++++--- test/fixtures/nested.js | 32 -------------------------------- 2 files changed, 29 insertions(+), 35 deletions(-) diff --git a/test/context-coloring-test.el b/test/context-coloring-test.el index a428dd6..d997d8b 100644 --- a/test/context-coloring-test.el +++ b/test/context-coloring-test.el @@ -20,8 +20,34 @@ FIXTURE." (context-coloring-mode) ,@body)) -(ert-deftest context-coloring-test-nested () - (context-coloring-test-with-fixture "./fixtures/nested.js" - )) +(defun context-coloring-test-region-level-p (start end level) + (let ((i 0) + (length (- end start))) + (while (< i length) + (let ((point (+ i start))) + (should (equal (get-text-property point 'face) + (intern-soft (concat "context-coloring-level-" + (number-to-string level) + "-face"))))) + (setq i (+ i 1))))) + +(ert-deftest context-coloring-test-function-scopes () + (context-coloring-test-with-fixture + "./fixtures/function-scopes.js" + + (sleep-for .25) ; Wait for asynchronous coloring to complete. + + (context-coloring-test-region-level-p 1 9 0) + (context-coloring-test-region-level-p 9 23 1) + (context-coloring-test-region-level-p 23 25 0) + (context-coloring-test-region-level-p 25 34 1) + (context-coloring-test-region-level-p 34 35 0) + (context-coloring-test-region-level-p 35 52 1) + (context-coloring-test-region-level-p 52 66 2) + (context-coloring-test-region-level-p 66 72 1) + (context-coloring-test-region-level-p 72 81 2) + (context-coloring-test-region-level-p 81 82 1) + (context-coloring-test-region-level-p 82 87 2) + (context-coloring-test-region-level-p 87 89 1))) (provide 'context-coloring-test) diff --git a/test/fixtures/nested.js b/test/fixtures/nested.js deleted file mode 100644 index 1621e06..0000000 --- a/test/fixtures/nested.js +++ /dev/null @@ -1,32 +0,0 @@ -function a() { - var A = a; - function b() { - var B = b; - function c() { - var C = c; - function d() { - var D = d; - function e() { - var E = e; - function f() { - var F = f; - function g() { - var G = g; - function h() { - var H = [ - A, - B, - C, - D, - E, - F, - G - ]; - } - } - } - } - } - } - } -}