[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/buttercup 0a281ed917 4/6: Handle no-signal case separately
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/buttercup 0a281ed917 4/6: Handle no-signal case separately in buttercup--handle-to-throw |
Date: |
Thu, 5 Oct 2023 19:00:19 -0400 (EDT) |
branch: elpa/buttercup
commit 0a281ed9178c1816c6d0ae3b52a056a5585dc189
Author: Ola Nilsson <ola.nilsson@gmail.com>
Commit: Ola Nilsson <ola.nilsson@gmail.com>
Handle no-signal case separately in buttercup--handle-to-throw
Checking for no signal first eliminates the need for the result-fmt
variable.
Shorten the message when an expression unexpectedly do not throw.
---
buttercup.el | 27 ++++++++++++++-------------
tests/test-buttercup.el | 4 ++--
2 files changed, 16 insertions(+), 15 deletions(-)
diff --git a/buttercup.el b/buttercup.el
index 67c5c254c7..f42d901486 100644
--- a/buttercup.el
+++ b/buttercup.el
@@ -684,19 +684,20 @@ UNEVALUATED-EXPR if it did not raise any signal."
"a signal")
?a (if expected-signal-args
(format " with args `%S'" expected-signal-args)
- "")))
- (result-fmt (if thrown-signal
- "it threw `%S' with args %A"
- "it evaluated successfully, returning value `%e'")))
- (buttercup--test-expectation matched
- :expect-match-phrase
- (buttercup--simple-format
- spec
- "Expected `%E' to throw %s%a, but instead " result-fmt)
- :expect-mismatch-phrase
- (buttercup--simple-format
- spec
- "Expected `%E' not to throw %s%a, but " result-fmt)))))
+ ""))))
+ (if (null thrown-signal)
+ ;; Match is not possible unless a signal was raied
+ (cons nil (buttercup--simple-format spec "Expected `%E' to throw
%s%a, but instead it returned `%e'"))
+ ;; non-matching signal
+ (buttercup--test-expectation matched
+ :expect-match-phrase
+ (buttercup--simple-format
+ spec
+ "Expected `%E' to throw %s%a, but instead it threw `%S' with args
%A")
+ :expect-mismatch-phrase
+ (buttercup--simple-format
+ spec
+ "Expected `%E' not to throw %s%a, but it threw `%S' with args
%A"))))))
(buttercup-define-matcher :to-have-been-called (spy)
(cl-assert (symbolp (funcall spy)))
diff --git a/tests/test-buttercup.el b/tests/test-buttercup.el
index 45ca903b42..373e9e0859 100644
--- a/tests/test-buttercup.el
+++ b/tests/test-buttercup.el
@@ -653,13 +653,13 @@ text properties using `ansi-color-apply'."
:to-throw
(mapcar #'buttercup--wrap-expr '((identity t))))
:to-equal
- '(nil . "Expected `(identity t)' to throw a signal, but
instead it evaluated successfully, returning value `t'")))
+ '(nil . "Expected `(identity t)' to throw a signal, but
instead it returned `t'")))
(it "and mention any specified signal"
(expect (buttercup--apply-matcher
:to-throw
(mapcar #'buttercup--wrap-expr '((identity t) 'arith-error)))
:to-equal
- '(nil . "Expected `(identity t)' to throw a child signal of
`arith-error', but instead it evaluated successfully, returning value `t'")))
+ '(nil . "Expected `(identity t)' to throw a child signal of
`arith-error', but instead it returned `t'")))
)
)
- [nongnu] elpa/buttercup updated (9cbbc9999e -> 3780eb0819), ELPA Syncer, 2023/10/05
- [nongnu] elpa/buttercup dfef8cf9c8 1/6: test: Allow linebreaks in pretty backtraces, ELPA Syncer, 2023/10/05
- [nongnu] elpa/buttercup b275ade3dc 3/6: Update copyrights, ELPA Syncer, 2023/10/05
- [nongnu] elpa/buttercup 38467b6b5f 5/6: Exclude signal args in :to-throw messages unless specified, ELPA Syncer, 2023/10/05
- [nongnu] elpa/buttercup 8ef60446ba 2/6: Test on GNU Emacs 29.1, ELPA Syncer, 2023/10/05
- [nongnu] elpa/buttercup 3780eb0819 6/6: Bump version: 1.31 → 1.32, ELPA Syncer, 2023/10/05
- [nongnu] elpa/buttercup 0a281ed917 4/6: Handle no-signal case separately in buttercup--handle-to-throw,
ELPA Syncer <=