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

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

[elpa] master 2ff0671 2/8: Add automated testing


From: Oleh Krehel
Subject: [elpa] master 2ff0671 2/8: Add automated testing
Date: Fri, 30 Jan 2015 16:18:50 +0000

branch: master
commit 2ff0671e47ed4843f5f69610e97e1e2245737955
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>

    Add automated testing
    
    * hydra-test.el (defhydra): Add test.
---
 .travis.yml   |   12 ++++++
 Makefile      |   12 ++++++
 hydra-test.el |  110 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 134 insertions(+), 0 deletions(-)

diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..1f5dbc7
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,12 @@
+language: emacs-lisp
+env:
+  matrix:
+    - EMACS=emacs24
+
+before_install:
+  - sudo add-apt-repository -y ppa:cassou/emacs
+  - sudo apt-get update -qq
+  - sudo apt-get install -qq $EMACS
+
+script:
+  - make test
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..97bcea6
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,12 @@
+EMACS = emacs
+# EMACS = emacs-24.3
+
+.PHONY: all test clean
+
+all: test
+
+test:
+       $(EMACS) -batch -l hydra.el -l hydra-test.el -f 
ert-run-tests-batch-and-exit
+
+clean:
+       rm -f *.elc
diff --git a/hydra-test.el b/hydra-test.el
new file mode 100644
index 0000000..8ee56eb
--- /dev/null
+++ b/hydra-test.el
@@ -0,0 +1,110 @@
+(require 'ert)
+
+(ert-deftest defhydra ()
+  (should
+   (equal
+    (macroexpand
+     '(defhydra hydra-error (global-map "M-g")
+       "error"
+       ("h" first-error "first")
+       ("j" next-error "next")
+       ("k" previous-error "prev")))
+    '(progn
+      (defun hydra-error/first-error ()
+        "Create a hydra with a \"M-g\" body and the heads:
+
+\"h\":    `first-error',
+\"j\":    `next-error',
+\"k\":    `previous-error'
+
+The body can be accessed via `hydra-error/body'.
+
+Call the head: `first-error'."
+        (interactive)
+        (call-interactively #'first-error)
+        (when hydra-is-helpful
+          (message #("error: [h]: first, [j]: next, [k]: prev."
+                     8 9 (face font-lock-keyword-face)
+                     20 21 (face font-lock-keyword-face)
+                     31 32 (face font-lock-keyword-face))))
+        (setq hydra-last
+              (hydra-set-transient-map
+               '(keymap
+                 (107 . hydra-error/previous-error)
+                 (106 . hydra-error/next-error)
+                 (104 . hydra-error/first-error)) t)))
+
+      (defun hydra-error/next-error ()
+        "Create a hydra with a \"M-g\" body and the heads:
+
+\"h\":    `first-error',
+\"j\":    `next-error',
+\"k\":    `previous-error'
+
+The body can be accessed via `hydra-error/body'.
+
+Call the head: `next-error'."
+        (interactive)
+        (call-interactively #'next-error)
+        (when hydra-is-helpful
+          (message #("error: [h]: first, [j]: next, [k]: prev."
+                     8 9 (face font-lock-keyword-face)
+                     20 21 (face font-lock-keyword-face)
+                     31 32 (face font-lock-keyword-face))))
+        (setq hydra-last
+              (hydra-set-transient-map
+               '(keymap
+                 (107 . hydra-error/previous-error)
+                 (106 . hydra-error/next-error)
+                 (104 . hydra-error/first-error)) t)))
+      
+      (defun hydra-error/previous-error ()
+        "Create a hydra with a \"M-g\" body and the heads:
+
+\"h\":    `first-error',
+\"j\":    `next-error',
+\"k\":    `previous-error'
+
+The body can be accessed via `hydra-error/body'.
+
+Call the head: `previous-error'."
+        (interactive)
+        (call-interactively #'previous-error)
+        (when hydra-is-helpful
+          (message #("error: [h]: first, [j]: next, [k]: prev."
+                     8 9 (face font-lock-keyword-face)
+                     20 21 (face font-lock-keyword-face)
+                     31 32 (face font-lock-keyword-face))))
+        (setq hydra-last
+              (hydra-set-transient-map
+               '(keymap
+                 (107 . hydra-error/previous-error)
+                 (106 . hydra-error/next-error)
+                 (104 . hydra-error/first-error)) t)))
+      
+      (unless (keymapp (lookup-key global-map (kbd "M-g")))
+        (define-key global-map (kbd "M-g") nil))
+      (define-key global-map [134217831 104] #'hydra-error/first-error)
+      (define-key global-map [134217831 106] #'hydra-error/next-error)
+      (define-key global-map [134217831 107] #'hydra-error/previous-error)
+      
+      (defun hydra-error/body ()
+        "Create a hydra with a \"M-g\" body and the heads:
+
+\"h\":    `first-error',
+\"j\":    `next-error',
+\"k\":    `previous-error'
+
+The body can be accessed via `hydra-error/body'."
+        (interactive)
+        (when hydra-is-helpful
+          (message #("error: [h]: first, [j]: next, [k]: prev."
+                     8 9 (face font-lock-keyword-face)
+                     20 21 (face font-lock-keyword-face)
+                     31 32 (face font-lock-keyword-face))))
+        (setq hydra-last
+              (hydra-set-transient-map
+               '(keymap
+                 (107 . hydra-error/previous-error)
+                 (106 . hydra-error/next-error)
+                 (104 . hydra-error/first-error)) t)))))))



reply via email to

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