Skip to content

Commit

Permalink
Remove remaining uses of `buttercup--mark-stackframe'
Browse files Browse the repository at this point in the history
Recent changes in the backtrace code has made
`buttercup--mark-stackframe' redundant.  Remove all uses and mentions
in code and tests.
  • Loading branch information
snogge committed Aug 27, 2024
1 parent add32f8 commit f577efc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 19 deletions.
14 changes: 4 additions & 10 deletions buttercup.el
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ For Emacs < 29:
The function MUST be byte-compiled or have one of the following
forms:
\(closure (ENVLIST) () (quote EXPR) (buttercup--mark-stackframe) EXPANDED)
\(lambda () (quote EXPR) (buttercup--mark-stackframe) EXPR)
\(closure (ENVLIST) () (quote EXPR) EXPANDED)
\(lambda () (quote EXPR) 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'
Expand All @@ -98,7 +98,7 @@ ensures access to the un-expanded form."
;; * the stackframe marker
;; * the macroexpanded original expression
(`(closure ,(pred listp) nil
(quote ,expr) (buttercup--mark-stackframe) ,_expanded)
(quote ,expr) ,_expanded)
expr)
;; This a when FUN has not been evaluated.
;; Why does that happen?
Expand All @@ -107,7 +107,7 @@ ensures access to the un-expanded form."
;; * the stackframe marker
;; * the expanded expression
(`(lambda nil
(quote ,expr) (buttercup--mark-stackframe) ,_expanded)
(quote ,expr) ,_expanded)
expr)
;; This is when FUN has been byte compiled, as when the entire
;; test file has been byte compiled. Check that it has an empty
Expand Down Expand Up @@ -188,11 +188,9 @@ Does not have the IGNORE-MISSING and SPLIT parameters."
"Wrap EXPR in a `buttercup--thunk' to be used by `buttercup-expect'."
(if (fboundp 'oclosure-lambda) ;Emacs≥29
`(oclosure-lambda (buttercup--thunk (expr ',expr)) ()
(buttercup--mark-stackframe)
,expr)
`(lambda ()
(quote ,expr)
(buttercup--mark-stackframe)
,expr)))

(defmacro expect (arg &optional matcher &rest args)
Expand Down Expand Up @@ -1015,7 +1013,6 @@ most probably including one or more calls to `expect'."
`(buttercup-it ,description
(lambda ()
(buttercup-with-converted-ert-signals
(buttercup--mark-stackframe)
,@body)))
`(buttercup-xit ,description)))

Expand Down Expand Up @@ -2111,9 +2108,6 @@ ARGS according to `debugger'."
((buttercup-pending buttercup-failed))
(otherwise (buttercup--backtrace)))))))

(defalias 'buttercup--mark-stackframe #'ignore
"Marker to find where the backtrace start.")

(defun buttercup--backtrace ()
"Create a backtrace, a list of frames returned from `backtrace-frame'."
;; Read the backtrace frames from `buttercup--debugger' + 1 upward.
Expand Down
17 changes: 8 additions & 9 deletions tests/test-buttercup.el
Original file line number Diff line number Diff line change
Expand Up @@ -180,18 +180,18 @@ before it's processed by other functions."
"Not testable on Emacs 30+, not relevant for Emacs 29+")
(expect (buttercup--enclosed-expr
(let ((_foo 1))
(lambda () '(ignore) (buttercup--mark-stackframe) (ignore))))
(lambda () '(ignore) (ignore))))
:to-equal '(ignore)))
(it "a lambda with expression copy?"
;; I suspect there is nothing to make sure that the quoted
;; expression matches the actual expression
(expect (buttercup--enclosed-expr
'(lambda () (quote (ignore)) (buttercup--mark-stackframe) (ignore))))
'(lambda () (quote (ignore)) (ignore))))
:to-equal '(ignore))
(describe "byte compiled"
(it "lambda objects"
(expect (buttercup--enclosed-expr
(byte-compile-sexp '(lambda () '(ignore) (buttercup--mark-stackframe) (ignore))))))
(byte-compile-sexp '(lambda () '(ignore) (ignore))))))
(it "wrapped expression"
(assume (not (fboundp 'buttercup--thunk-p)) "Not with Oclosures")
(expect (buttercup--enclosed-expr (byte-compile-sexp (buttercup--wrap-expr '(ignore))))))))
Expand All @@ -202,23 +202,23 @@ before it's processed by other functions."
:to-throw 'buttercup-enclosed-expression-error))
(it "on a closure with stackframe marker but no quoted expression"
(expect
(buttercup--enclosed-expr (let ((_foo 1)) (lambda () (buttercup--mark-stackframe) (ignore))))
(buttercup--enclosed-expr (let ((_foo 1)) (lambda () (ignore))))
:to-throw 'buttercup-enclosed-expression-error))
(it "for multi-statement closures"
(expect (buttercup--enclosed-expr
(lambda () '(+ 1 2) (buttercup--mark-stackframe) (+ 1 2) (ignore)))
(lambda () '(+ 1 2) (+ 1 2) (ignore)))
:to-throw 'buttercup-enclosed-expression-error))
(it "for closures with non-empty argument lists"
(expect (buttercup--enclosed-expr
(lambda (foo) '(ignore foo) (buttercup--mark-stackframe) (ignore foo)))
(lambda (foo) '(ignore foo) (ignore foo)))
:to-throw 'buttercup-enclosed-expression-error))
(it "on simple lambda objects"
(expect (buttercup--enclosed-expr
'(lambda () (ignore)))
:to-throw))
(it "on a lambda with stackframe marker but no quoted expression"
(expect (buttercup--enclosed-expr
'(lambda () (buttercup--mark-stackframe) (ignore)))
'(lambda () (ignore)))
:to-throw 'buttercup-enclosed-expression-error))
(it "for multi-statement lambdas"
(expect (buttercup--enclosed-expr
Expand All @@ -230,7 +230,7 @@ before it's processed by other functions."
:to-throw 'buttercup-enclosed-expression-error))
(it "on byte-compiled functions with arguments"
(expect (buttercup--enclosed-expr
(byte-compile-sexp '(lambda (_a) '(ignore) (buttercup--mark-stackframe) (ignore))))
(byte-compile-sexp '(lambda (_a) '(ignore) (ignore))))
:to-throw 'buttercup-enclosed-expression-error))))

;;;;;;;;;;
Expand Down Expand Up @@ -1121,7 +1121,6 @@ before it's processed by other functions."
'(buttercup-it "description"
(lambda ()
(buttercup-with-converted-ert-signals
(buttercup--mark-stackframe)
body)))))

(it "without argument should expand to xit."
Expand Down

0 comments on commit f577efc

Please sign in to comment.