[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/buttercup 0e26b1bbed 6/9: Clean up buttercup--enclosed-exp
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/buttercup 0e26b1bbed 6/9: Clean up buttercup--enclosed-expr |
Date: |
Wed, 10 Aug 2022 18:58:14 -0400 (EDT) |
branch: elpa/buttercup
commit 0e26b1bbed3da4b86c621e8ad18843657e59c063
Author: Ola Nilsson <ola.nilsson@gmail.com>
Commit: Ola Nilsson <ola.nilsson@gmail.com>
Clean up buttercup--enclosed-expr
There are only two valid forms of FUN, and one of them is probably
only for special cases when testing buttercup itself.
---
buttercup.el | 53 +++++++++++++++++++++++++++++------------------------
1 file changed, 29 insertions(+), 24 deletions(-)
diff --git a/buttercup.el b/buttercup.el
index 418dd5ecae..1fdfc74b5b 100644
--- a/buttercup.el
+++ b/buttercup.el
@@ -59,31 +59,36 @@
The function MUST have one of the following forms:
-\(lambda () EXPR)
-\(lambda () (buttercup--mark-stackframe) EXPR)
-\(closure (ENVLIST) () EXPR)
-\(closure (ENVLIST) () (buttercup--mark-stackframe) EXPR)
-\(lambda () (quote EXPR) EXPR)
-\(closure (ENVLIST) () (quote EXPR) EXPR)
-
-and the return value will be EXPR, unevaluated. The latter 2
-forms are useful if EXPR is a macro call, in which case the
-`quote' ensures access to the un-expanded form."
+\(closure (ENVLIST) () (quote EXPR) (buttercup--mark-stackframe) EXPANDED)
+\(lambda () (quote EXPR) (buttercup--mark-stackframe) EXPR)
+
+and the return value will be EXPR, unevaluated. The quoted EXPR
+is useful if EXPR is a macro call, in which case the `quote'
+ensures access to the un-expanded form."
+ (cl-assert (functionp fun) t "Expected FUN to be a function")
(pcase fun
- (`(closure ,(pred listp) nil ,expr) expr)
- (`(closure ,(pred listp) nil (buttercup--mark-stackframe) ,expr) expr)
- (`(closure ,(pred listp) nil (quote ,expr) . ,_rest) expr)
- (`(closure ,(pred listp) nil ,_expr . ,(pred identity))
- (error "Closure contains multiple expressions: %S" fun))
- (`(closure ,(pred listp) ,(pred identity) . ,(pred identity))
- (error "Closure has nonempty arglist: %S" fun))
- (`(lambda nil ,expr) expr)
- (`(lambda nil (buttercup--mark-stackframe) ,expr) expr)
- (`(lambda nil (quote ,expr) . ,_rest) expr)
- (`(lambda nil ,_expr . ,(pred identity))
- (error "Function contains multiple expressions: %S" fun))
- (`(lambda ,(pred identity) . ,(pred identity))
- (error "Function has nonempty arglist: %S" fun))
+ ;; This should be the normal case, a closure with unknown enclosed
+ ;; variables, empty arglist and a body containing
+ ;; * the quoted original expression
+ ;; * the stackframe marker
+ ;; * the macroexpanded original expression
+ (`(closure ,(pred listp) nil
+ (quote ,expr) (buttercup--mark-stackframe) ,_expanded)
+ expr)
+ ;; This a when FUN has not been evaluated. Probably never happens
+ ;; except when testing buttercup. Should probably do something
+ ;; about that.
+ ;; A lambda with an empty arglist and a body containing
+ ;; * the quoted original expression
+ ;; * the stackframe marker
+ ;; * the original expression
+ ;; In this case expr and expr2 should be equal (but not eq?) as
+ ;; expr2 has not been macroexpanded.
+ ((and `(lambda nil
+ (quote ,expr) (buttercup--mark-stackframe) ,expr2)
+ (guard (equal expr expr2)))
+ expr)
+ ;; Error
(_ (error "Not a zero-arg one-expression closure: %S" fun))))
(defun buttercup--expr-and-value (fun)
- [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, 2022/08/10
- [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 <=
- [nongnu] elpa/buttercup cdbb8b061d 7/9: tests: Add tests for buttercup--enclosed-expr, ELPA Syncer, 2022/08/10