[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/buttercup f44e65d 004/340: Unit tests for define-matcher a
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/buttercup f44e65d 004/340: Unit tests for define-matcher and apply-matcher. |
Date: |
Thu, 16 Dec 2021 14:58:54 -0500 (EST) |
branch: elpa/buttercup
commit f44e65d6c7e0fa7482308cf69f7b309f68899d83
Author: Jorgen Schaefer <contact@jorgenschaefer.de>
Commit: Jorgen Schaefer <contact@jorgenschaefer.de>
Unit tests for define-matcher and apply-matcher.
---
buttercup-test.el | 27 +++++++++++++++++++++------
buttercup.el | 3 +++
2 files changed, 24 insertions(+), 6 deletions(-)
diff --git a/buttercup-test.el b/buttercup-test.el
index 0b123b9..abc6daf 100644
--- a/buttercup-test.el
+++ b/buttercup-test.el
@@ -82,11 +82,26 @@
'buttercup-failed "Explanation")))
(describe "The `buttercup-define-matcher' macro"
- (it "should add a buttercup-matcher property"
- (buttercup-define-matcher :test-matcher (a b)
- (+ a b))
+ (buttercup-define-matcher :test-matcher (a b)
+ (+ a b))
- (expect (funcall (get :test-matcher 'buttercup-matcher)
- 1 2)
+ (it "should create a matcher usable by apply-matcher"
+ (expect (buttercup--apply-matcher :test-matcher '(1 2))
:to-equal
- 3)))
+ 3))
+
+ (describe "The `buttercup--apply-matcher'"
+ (it "should work with functions"
+ (expect (buttercup--apply-matcher #'+ '(1 2))
+ :to-equal
+ 3))
+
+ (it "should work with matchers"
+ (expect (buttercup--apply-matcher :test-matcher '(1 2))
+ :to-equal
+ 3))
+
+ (it "should fail if the matcher is not defined"
+ (expect (lambda ()
+ (buttercup--apply-matcher :not-defined '(1 2)))
+ :to-throw))))
diff --git a/buttercup.el b/buttercup.el
index 4997e6d..baff39e 100644
--- a/buttercup.el
+++ b/buttercup.el
@@ -104,7 +104,10 @@ should describe why a negated matcher failed."
,@body)))
(defun buttercup--apply-matcher (matcher args)
+ "Apply MATCHER to ARGS.
+MATCHER is either a matcher defined with
+`buttercup-define-matcher', or a function."
(let ((function (or (get matcher 'buttercup-matcher)
matcher)))
(when (not (functionp function))
- [nongnu] elpa/buttercup 5d369cd 007/340: Do not use emacs-snapshot from EVM, that's slow., (continued)
- [nongnu] elpa/buttercup 5d369cd 007/340: Do not use emacs-snapshot from EVM, that's slow., ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 07b1ee6 008/340: Add compatibility definition for define-error, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 7cdb219 028/340: Spies: :and-call-fake, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 5db449f 025/340: Spies, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup d580e5c 011/340: Add build status badge., ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 3637e3d 015/340: Add more extensive matcher tests to the README., ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup a277b0e 022/340: Setup and teardown: before-each, after-each, before-all, after-all, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 1882d6f 013/340: Comment cleanup. Also, make elisp lexically scoped., ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup c5a9f26 003/340: Add first set of unit tests., ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 36522b9 006/340: Add .travis.yml, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup f44e65d 004/340: Unit tests for define-matcher and apply-matcher.,
ELPA Syncer <=
- [nongnu] elpa/buttercup d3cd12a 019/340: Tests for the buttercup-describe function, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 3772ad5 014/340: Use eval-region instead of eval-buffer., ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 8aa87c8 026/340: Spy :and-call-through, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 683614d 018/340: Tests for the describe macro., ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 0221830 023/340: Remove setup and teardown from ROADMAP.md., ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 695e444 016/340: buttercup-markdown-runner: Use setq, not setq-local., ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 7526198 029/340: Spies: :and-throw-error, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 77d1dac 017/340: Test buttercup-suite-add-child., ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup c1abc2a 033/340: Refactoring of spy context accessors., ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup f314737 035/340: ROADMAP.md: Remove spies section, as it is done., ELPA Syncer, 2021/12/16