[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/buttercup 0124cc4 129/340: Signal an error when ":to-throw
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/buttercup 0124cc4 129/340: Signal an error when ":to-throw" is used on a non-function (#97) |
Date: |
Thu, 16 Dec 2021 14:59:18 -0500 (EST) |
branch: elpa/buttercup
commit 0124cc415a80987988b3af8a7d55633559bd6153
Author: Ryan C. Thompson <rct@thompsonclan.org>
Commit: Jorgen Schäfer <Jorgen.Schaefer@gmail.com>
Signal an error when ":to-throw" is used on a non-function (#97)
* Signal an error when ":to-throw" is used on a non-function
Fixes #53.
* Add a test for using :to-throw on non-functions
---
buttercup.el | 4 ++++
docs/writing-tests.md | 7 ++++++-
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/buttercup.el b/buttercup.el
index 4d5dc3c..4389902 100644
--- a/buttercup.el
+++ b/buttercup.el
@@ -203,6 +203,10 @@ MATCHER is either a matcher defined with
a b precision))))
(buttercup-define-matcher :to-throw (function &optional signal signal-args)
+ ;; This will trigger errors relating to FUNCTION not being a
+ ;; function outside the following `condition-case'.
+ (when (not (functionp function))
+ (funcall function))
(condition-case err
(progn
(funcall function)
diff --git a/docs/writing-tests.md b/docs/writing-tests.md
index 007d1d9..2bb5dbc 100644
--- a/docs/writing-tests.md
+++ b/docs/writing-tests.md
@@ -165,7 +165,12 @@ that are not included below.
(let ((foo (lambda () (+ a 1)))
(bar (lambda () (+ a 1))))
(expect foo :not :to-throw 'void-variable '(b))
- (expect bar :to-throw 'void-variable '(a))))))
+ (expect bar :to-throw 'void-variable '(a))))
+ (it "only works on functions"
+ (expect (lambda () (expect nil :to-throw 'error))
+ :to-throw 'void-function)
+ (expect (lambda () (expect "hello" :not :to-throw 'error))
+ :to-throw 'invalid-function))))
```
## Grouping Related Specs with `describe`
- [nongnu] elpa/buttercup 4f68f0b 059/340: The buttercup-spec-full-name function., (continued)
- [nongnu] elpa/buttercup 4f68f0b 059/340: The buttercup-spec-full-name function., ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup ef7b730 063/340: Various improvements of the batch reporter., ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup a55a638 064/340: More and better tests for the batch reporter., ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup c7df9f6 069/340: Add 24.5., ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 0c5cc32 057/340: The buttercup-suites-total-specs-defined function., ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup ea8effb 095/340: Add the :var argument to describe, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 23472e9 099/340: :to-match: Show correct error messages, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup cc52444 107/340: feature/windows-bin-support: support for windows, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 3ef90b4 100/340: :to-match: Don't switch t/nil!, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup ab2a558 111/340: Add projectile integration info to Readme, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 0124cc4 129/340: Signal an error when ":to-throw" is used on a non-function (#97),
ELPA Syncer <=
- [nongnu] elpa/buttercup 31e765b 142/340: Do not suppress errors while loading test files, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup bc13b53 183/340: Merge pull request #133 from snogge/fix-specs-in-pending-suites, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup ca3ba8e 185/340: Merge pull request #130 from snogge/travis-update, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup d6cf530 072/340: Clean up the interactive reporter., ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 68c5ef5 076/340: Only load .el files during discovery., ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 14718c0 081/340: Use the new Travis infrastructure, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup d00c164 083/340: Display description for pending specs, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup ad901b5 149/340: Do not modify global match data in matchers, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup c1187b3 152/340: Extract function buttercup-suites-total-spces-status, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup f565eda 157/340: Extract super-struct buttercup-suite-or-spec, ELPA Syncer, 2021/12/16