[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/dash 0ef7384 395/439: Merge pull request #114 from fber
From: |
Phillip Lord |
Subject: |
[elpa] externals/dash 0ef7384 395/439: Merge pull request #114 from fbergroth/update-test-case |
Date: |
Tue, 04 Aug 2015 20:31:08 +0000 |
branch: externals/dash
commit 0ef7384c0085248b5674a20fa7bc726da1916066
Merge: 26c1bbe c34e4ab
Author: Magnar Sveen <address@hidden>
Commit: Magnar Sveen <address@hidden>
Merge pull request #114 from fbergroth/update-test-case
Update error tests
---
dev/examples-to-tests.el | 23 +++++++++++++++--------
dev/examples.el | 38 ++++++++++++++++----------------------
run-tests.sh | 2 +-
3 files changed, 32 insertions(+), 31 deletions(-)
diff --git a/dev/examples-to-tests.el b/dev/examples-to-tests.el
index 6cee1a3..49d6649 100644
--- a/dev/examples-to-tests.el
+++ b/dev/examples-to-tests.el
@@ -1,15 +1,22 @@
(require 'ert)
-(require 'dash)
-(require 'dash-functional)
-(defun example-to-should (example)
- (let ((actual (car example))
- (expected (nth 2 example)))
- `(should (equal ,actual ,expected))))
+(defun example-to-should (actual sym expected)
+ (cond ((eq sym '=>)
+ `(should (equal ,actual ,expected)))
+ ((eq sym '!!>)
+ `(should-error (eval ',actual) :type ',expected))
+ (t
+ (error "invalid test case: %S" `(,actual ,sym ,expected)))))
+
(defmacro defexamples (cmd &rest examples)
- `(ert-deftest ,cmd ()
- ,@(-map 'example-to-should (-partition 3 examples))))
+ (let ((tests))
+ (while examples
+ (push (example-to-should (pop examples)
+ (pop examples)
+ (pop examples))
+ tests))
+ `(ert-deftest ,cmd () ,@(nreverse tests))))
(defun def-example-group (&rest _)) ; ignore
diff --git a/dev/examples.el b/dev/examples.el
index 7e25d16..79ac244 100644
--- a/dev/examples.el
+++ b/dev/examples.el
@@ -574,8 +574,8 @@ new list."
(defexamples -list
(-list 1) => '(1)
(-list 1 2 3) => '(1 2 3)
- (-list '(1 2 3) => '(1 2 3))
- (-list '((1) (2)) => '((1) (2))))
+ (-list '(1 2 3)) => '(1 2 3)
+ (-list '((1) (2))) => '((1) (2)))
(defexamples -fix
(-fix (lambda (l) (-non-nil (--mapcat (-split-at (/ (length it) 2) it)
l))) '((1 2 3 4 5 6))) => '((1) (2) (3) (4) (5) (6))
@@ -739,12 +739,7 @@ new list."
(-let [[a b &rest [c d]] [1 2 3 4 5 6]] (list a b c d)) => '(1 2 3 4)
;; here we error, because "vectors" are rigid, immutable structures,
;; so we should know how many elements there are
- (condition-case nil
- (-let [[a b c d] [1 2 3]]
- (progn
- (list a b c d)
- (error "previous call should fail.")))
- (args-out-of-range t)) => t
+ (-let [[a b c d] [1 2 3]] t) !!> args-out-of-range
(-let [(a . (b . c)) (cons 1 (cons 2 3))] (list a b c)) => '(1 2 3)
(-let [(_ _ . [a b]) (cons 1 (cons 2 (vector 3 4)))] (list a b)) => '(3 4)
(-let [(_ _ . (a b)) (cons 1 (cons 2 (list 3 4)))] (list a b)) => '(3 4)
@@ -838,7 +833,7 @@ new list."
(-map (-lambda ((&plist :a a :b b)) (+ a b)) '((:a 1 :b 2) (:a 3 :b 4) (:a
5 :b 6))) => '(3 7 11)
(-map (-lambda (x) (let ((k (car x)) (v (cadr x))) (+ k v))) '((1 2) (3 4)
(5 6))) => '(3 7 11)
(funcall (-lambda ((a) (b)) (+ a b)) '(1 2 3) '(4 5 6)) => 5
- (condition-case nil (progn (-lambda a t) (error "previous form should
error")) (wrong-type-argument t)) => t
+ (-lambda a t) !!> wrong-type-argument
(funcall (-lambda (a b) (+ a b)) 1 2) => 3
(funcall (-lambda (a (b c)) (+ a b c)) 1 (list 2 3)) => 6))
@@ -951,7 +946,7 @@ new list."
(equal (funcall (-iteratefn fn 3) init)
(-last-item (-iterate fn init (1+ 3))))
(equal (funcall (-iteratefn fn 5) init)
- (-last-item (-iterate fn init (1+ 5)))))))
+ (-last-item (-iterate fn init (1+ 5)))))) => t)
(defexamples -fixfn
;; Find solution to cos(x) = x
@@ -970,18 +965,17 @@ new list."
(input '(1 2))
(input2 "foo")
(input3 '("10" '(1 2 3))))
- (equal (funcall (-prodfn f g) input)
- (funcall (-juxt (-compose f (-partial 'nth 0)) (-compose g
(-partial 'nth 1))) input))
- (equal (funcall (-compose (-prodfn f g) (-juxt ff gg)) input2)
- (funcall (-juxt (-compose f ff) (-compose g gg)) input2))
- (equal (funcall (-compose (-partial 'nth 0) (-prod f g)) input)
- (funcall (-compose f (-partial 'nth 0)) input))
- (equal (funcall (-compose (-partial 'nth 1) (-prod f g)) input)
- (funcall (-compose g (-partial 'nth 1)) input))
- (equal (funcall (-compose (-prodfn f g) (-prodfn ff gg)) input3)
- (funcall (-prodfn (-compose f ff) (-compose g gg)) input3))))
- ))
+ (and (equal (funcall (-prodfn f g) input)
+ (funcall (-juxt (-compose f (-partial 'nth 0)) (-compose g
(-partial 'nth 1))) input))
+ (equal (funcall (-compose (-prodfn f g) (-juxt ff gg)) input2)
+ (funcall (-juxt (-compose f ff) (-compose g gg)) input2))
+ (equal (funcall (-compose (-partial 'nth 0) (-prodfn f g)) input)
+ (funcall (-compose f (-partial 'nth 0)) input))
+ (equal (funcall (-compose (-partial 'nth 1) (-prodfn f g)) input)
+ (funcall (-compose g (-partial 'nth 1)) input))
+ (equal (funcall (-compose (-prodfn f g) (-prodfn ff gg)) input3)
+ (funcall (-prodfn (-compose f ff) (-compose g gg))
input3)))) => t)))
;; Local Variables:
-;; eval: (font-lock-add-keywords nil '(("defexamples\\|def-example-group\\| =>
" (0 'font-lock-keyword-face)) ("(defexamples[[:blank:]]+\\(.*\\)" (1
'font-lock-function-name-face))))
+;; eval: (font-lock-add-keywords nil '(("defexamples\\|def-example-group\\| =>
\\| !!> " (0 'font-lock-keyword-face)) ("(defexamples[[:blank:]]+\\(.*\\)" (1
'font-lock-function-name-face))))
;; End:
diff --git a/run-tests.sh b/run-tests.sh
index 74bc211..edaffe3 100755
--- a/run-tests.sh
+++ b/run-tests.sh
@@ -7,7 +7,7 @@ if [ -z "$EMACS" ] ; then
fi
$EMACS -batch \
- -l dev/ert.el \
+ $([[ $EMACS == "emacs23" ]] && echo -l dev/ert.el) \
-l dash.el \
-l dash-functional.el \
-l dev/examples-to-tests.el \
- [elpa] externals/dash 3b63476 412/439: Move anaphoric function intro up into Functions section, (continued)
- [elpa] externals/dash 3b63476 412/439: Move anaphoric function intro up into Functions section, Phillip Lord, 2015/08/04
- [elpa] externals/dash 19fbc24 426/439: Fix anaphoric -spice-list macro, Phillip Lord, 2015/08/04
- [elpa] externals/dash 2db56f5 424/439: [-let] Add support for &as bindings (#115), Phillip Lord, 2015/08/04
- [elpa] externals/dash ffa37bf 425/439: Merge pull request #129 from holomorph/docs, Phillip Lord, 2015/08/04
- [elpa] externals/dash 81b808d 409/439: Ignore dash.elc, Phillip Lord, 2015/08/04
- [elpa] externals/dash c61113b 420/439: [-let] Update outdated comment, Phillip Lord, 2015/08/04
- [elpa] externals/dash 733274f 398/439: Merge pull request #120 from holomorph/info-manual, Phillip Lord, 2015/08/04
- [elpa] externals/dash a803dd5 414/439: Merge readme changes, Phillip Lord, 2015/08/04
- [elpa] externals/dash 7bd6b3b 400/439: Add dir entry to texinfo template, Phillip Lord, 2015/08/04
- [elpa] externals/dash 5219ac0 422/439: [-let] Eliminate useless re-binding of symbols when sources are immutable, Phillip Lord, 2015/08/04
- [elpa] externals/dash 0ef7384 395/439: Merge pull request #114 from fbergroth/update-test-case,
Phillip Lord <=
- [elpa] externals/dash 349931e 399/439: Add @holomorph to list of contributors, Phillip Lord, 2015/08/04
- [elpa] externals/dash 1d4881f 413/439: Update README, Phillip Lord, 2015/08/04
- [elpa] externals/dash 36b7f49 419/439: [-let] Reuse the ignore-place predicate, Phillip Lord, 2015/08/04
- [elpa] externals/dash b308794 416/439: [Fix #73] Add a mention of -filter to -keep docstring, Phillip Lord, 2015/08/04
- [elpa] externals/dash 51a07b1 408/439: Merge pull request #127 from occidens/fixfn, Phillip Lord, 2015/08/04
- [elpa] externals/dash 8530742 410/439: Add @wasamasa and @occidens to list of contributors, Phillip Lord, 2015/08/04
- [elpa] externals/dash db784f8 403/439: Merge pull request #124 from occidens/skiptests, Phillip Lord, 2015/08/04
- [elpa] externals/dash 9ebd172 421/439: [-let] Generate differently named symbols for temporary sources (makes, Phillip Lord, 2015/08/04
- [elpa] externals/dash 7d7a457 402/439: Allow run-tests.sh to skip tests, Phillip Lord, 2015/08/04
- [elpa] externals/dash 3a3f528 396/439: Add info manual, Phillip Lord, 2015/08/04