[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/buttercup 8dda6ef8c9 2/9: Refactor the expect macro
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/buttercup 8dda6ef8c9 2/9: Refactor the expect macro |
Date: |
Wed, 10 Aug 2022 18:58:13 -0400 (EDT) |
branch: elpa/buttercup
commit 8dda6ef8c9e4f5f49a5c2b834ea83802b5ca5bf3
Author: Ola Nilsson <ola.nilsson@gmail.com>
Commit: Ola Nilsson <ola.nilsson@gmail.com>
Refactor the expect macro
Extract the wrapping of expressions into a separate function
buttercup--wrap-expr. This reduces code duplication.
---
buttercup.el | 23 ++++++++++-------------
1 file changed, 10 insertions(+), 13 deletions(-)
diff --git a/buttercup.el b/buttercup.el
index f32647b788..418dd5ecae 100644
--- a/buttercup.el
+++ b/buttercup.el
@@ -123,6 +123,13 @@ a call to `save-match-data', as `format-spec' modifies
that."
(define-error 'buttercup-pending "Buttercup test is pending"
'buttercup-error-base)
+(defun buttercup--wrap-expr (expr)
+ "Wrap EXPR to be used by `buttercup-expect'."
+ `(lambda ()
+ (quote ,expr)
+ (buttercup--mark-stackframe)
+ ,expr))
+
(defmacro expect (arg &optional matcher &rest args)
"Expect a condition to be true.
@@ -137,19 +144,9 @@ This macro knows three forms:
\(expect ARG)
Fail the current test if ARG is not true."
- (let ((wrapped-args
- (mapcar (lambda (expr) `(lambda ()
- (quote ,expr)
- (buttercup--mark-stackframe)
- ,expr))
- args)))
- `(buttercup-expect
- (lambda ()
- (quote ,arg)
- (buttercup--mark-stackframe)
- ,arg)
- ,(or matcher :to-be-truthy)
- ,@wrapped-args)))
+ `(buttercup-expect ,(buttercup--wrap-expr arg)
+ ,(or matcher :to-be-truthy)
+ ,@(mapcar #'buttercup--wrap-expr args)))
(defun buttercup-expect (arg &optional matcher &rest args)
"The function for the `expect' macro.
- [nongnu] elpa/buttercup updated (62176a39ee -> 497f6c2795), ELPA Syncer, 2022/08/10
- [nongnu] elpa/buttercup ec4d94f7d5 3/9: tests: Create enclosed expressions with buttercup--wrap-expr, ELPA Syncer, 2022/08/10
- [nongnu] elpa/buttercup ef293a62df 1/9: Fix: (buttercup--enclosed-expr) byte-code functions, ELPA Syncer, 2022/08/10
- [nongnu] elpa/buttercup 8dda6ef8c9 2/9: Refactor the expect macro,
ELPA Syncer <=
- [nongnu] elpa/buttercup 1bb0ba9439 8/9: Merge PR 219 into byte-compiled, ELPA Syncer, 2022/08/10
- [nongnu] elpa/buttercup 497f6c2795 9/9: Merge branch 'byte-compiled', ELPA Syncer, 2022/08/10
- [nongnu] elpa/buttercup 4cbd106609 5/9: tests: Use buttercup--wrap-expr instead of make-list-of-closures, ELPA Syncer, 2022/08/10
- [nongnu] elpa/buttercup 435fc0d378 4/9: tests: Fix some buttercup-expect tests, ELPA Syncer, 2022/08/10
- [nongnu] elpa/buttercup 0e26b1bbed 6/9: Clean up buttercup--enclosed-expr, ELPA Syncer, 2022/08/10
- [nongnu] elpa/buttercup cdbb8b061d 7/9: tests: Add tests for buttercup--enclosed-expr, ELPA Syncer, 2022/08/10