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

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

[elpa] master 588dab6 49/67: ivy-test.el: Add testing


From: Oleh Krehel
Subject: [elpa] master 588dab6 49/67: ivy-test.el: Add testing
Date: Sun, 22 Mar 2015 17:34:07 +0000

branch: master
commit 588dab6cb5ed0c42ff3436311a8d9f831a29724b
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>

    ivy-test.el: Add testing
    
    * Makefile: Add a test and compile target.
---
 .travis.yml |   12 ++++++++++++
 Makefile    |   16 ++++++++++++++++
 ivy-test.el |   46 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 74 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..453f709
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,16 @@
+emacs ?= emacs
+
+LOAD = -l ivy.el -l swiper.el
+
+.PHONY: all compile clean
+
+all: test
+
+test:
+       $(emacs) -batch $(LOAD) -l ivy-test.el -f ert-run-tests-batch-and-exit
+
+compile:
+       $(emacs) -batch $(LOAD) --eval "(mapc #'byte-compile-file '(\"ivy.el\" 
\"swiper.el\"))"
+
+clean:
+       rm -f *.elc
diff --git a/ivy-test.el b/ivy-test.el
new file mode 100644
index 0000000..af17414
--- /dev/null
+++ b/ivy-test.el
@@ -0,0 +1,46 @@
+(require 'ert)
+
+(defvar ivy-expr nil
+  "Holds a test expression to evaluate with `ivy-eval'.")
+
+(defvar ivy-result nil
+  "Holds the eval result of `ivy-expr' by `ivy-eval'.")
+
+(defun ivy-eval ()
+  "Evaluate `ivy-expr'."
+  (interactive)
+  (setq ivy-result (eval ivy-expr)))
+
+(global-set-key (kbd "C-c e") 'ivy-eval)
+
+(defun ivy-with (expr keys)
+  "Evaluate EXPR followed by KEYS."
+  (let ((ivy-expr expr))
+    (execute-kbd-macro
+     (vconcat (kbd "C-c e")
+              (kbd keys)))
+    ivy-result))
+
+(ert-deftest ivy-read ()
+  (should (equal
+           (ivy-read "pattern: " nil)
+           nil))
+  (should (equal
+           (ivy-read "pattern: " '("42"))
+           "42"))
+  (should (equal
+           (ivy-with '(ivy-read "pattern: " '("blue" "yellow"))
+                     "C-m")
+           "blue"))
+  (should (equal
+           (ivy-with '(ivy-read "pattern: " '("blue" "yellow"))
+                     "y C-m")
+           "yellow"))
+  (should (equal
+           (ivy-with '(ivy-read "pattern: " '("blue" "yellow"))
+                     "y DEL b C-m")
+           "blue"))
+  (should (equal
+           (ivy-with '(ivy-read "pattern: " '("blue" "yellow"))
+                     "z C-m")
+           nil)))



reply via email to

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