[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/buttercup 9b30c75 252/340: Make buttercup-x?it and butterc
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/buttercup 9b30c75 252/340: Make buttercup-x?it and buttercup-suite-add-child return spec |
Date: |
Thu, 16 Dec 2021 14:59:44 -0500 (EST) |
branch: elpa/buttercup
commit 9b30c755e43df7045c36e596ce31e0af597b594e
Author: Ola Nilsson <ola.nilsson@gmail.com>
Commit: Ola Nilsson <ola.nilsson@gmail.com>
Make buttercup-x?it and buttercup-suite-add-child return spec
Returning the buttercup-spec object from these function makes it
possible to write simpler code elsewhere, especially tests.
---
buttercup.el | 22 +++++++++++++---------
tests/test-buttercup.el | 19 +++++++++++--------
2 files changed, 24 insertions(+), 17 deletions(-)
diff --git a/buttercup.el b/buttercup.el
index e28cb01..14c8b35 100644
--- a/buttercup.el
+++ b/buttercup.el
@@ -691,11 +691,13 @@ See also `buttercup-define-matcher'."
function)
(defun buttercup-suite-add-child (parent child)
- "Add a CHILD suite to a PARENT suite."
+ "Add a CHILD suite to a PARENT suite.
+Return CHILD."
(setf (buttercup-suite-children parent)
(append (buttercup-suite-children parent)
(list child)))
- (setf (buttercup-suite-or-spec-parent child) parent))
+ (setf (buttercup-suite-or-spec-parent child) parent)
+ child)
(defun buttercup-suite-or-spec-parents (suite-or-spec)
"Return a list of parents of SUITE-OR-SPEC."
@@ -868,7 +870,8 @@ most probably including one or more calls to `expect'."
"Function to handle an `it' form.
DESCRIPTION has the same meaning as in `it'. BODY-FUNCTION is a
-function containing the body instructions passed to `it'."
+function containing the body instructions passed to `it'. Return
+the created spec object."
(declare (indent 1))
(when (not buttercup--current-suite)
(error "`it' has to be called from within a `describe' form"))
@@ -1006,17 +1009,18 @@ DESCRIPTION is a string. BODY is ignored."
"Like `buttercup-it', but mark the spec as disabled.
A disabled spec is not run.
-DESCRIPTION has the same meaning as in `xit'. FUNCTION is ignored."
+DESCRIPTION has the same meaning as in `xit'. FUNCTION is
+ignored. Return the created spec object."
(declare (indent 1))
(ignore function)
- (buttercup-it description (lambda ()
- (signal 'buttercup-pending "PENDING")))
- (let ((spec (car (last (buttercup-suite-children
- buttercup--current-suite)))))
+ (let ((spec (buttercup-it description
+ (lambda ()
+ (signal 'buttercup-pending "PENDING")))))
(setf (buttercup-spec-status spec)
'pending
(buttercup-spec-failure-description spec)
- "")))
+ "")
+ spec))
;;;;;;;;;
;;; Spies
diff --git a/tests/test-buttercup.el b/tests/test-buttercup.el
index a73f2ee..aa3cd95 100644
--- a/tests/test-buttercup.el
+++ b/tests/test-buttercup.el
@@ -179,24 +179,26 @@
;;; Suite and spec data structures
(describe "The `buttercup-suite-add-child' function"
- (it "should add an element at the end of the list"
+ (it "should add an element at the end of the list and return it"
(let* ((specs (list (make-buttercup-spec)
(make-buttercup-spec)
(make-buttercup-spec)))
(suite (make-buttercup-suite :children specs))
(spec (make-buttercup-spec)))
- (buttercup-suite-add-child suite spec)
+ (expect (buttercup-suite-add-child suite spec)
+ :to-be spec)
(expect (buttercup-suite-children suite)
:to-equal
(append specs (list spec)))))
- (it "should add an element even if the list is empty"
+ (it "should add an element even if the list is empty and return it"
(let ((suite (make-buttercup-suite :children nil))
(spec (make-buttercup-spec)))
- (buttercup-suite-add-child suite spec)
+ (expect (buttercup-suite-add-child suite spec)
+ :to-be spec)
(expect (buttercup-suite-children suite)
:to-equal
@@ -444,11 +446,12 @@
(buttercup-it "" (lambda ())))
:to-throw))
- (it "should add a spec to the current suite"
+ (it "should add a spec to the current suite and return the spec"
(let ((buttercup--current-suite (make-buttercup-suite)))
- (buttercup-it "the test spec"
- (lambda () 23))
- (let ((spec (car (buttercup-suite-children buttercup--current-suite))))
+ (let* ((created (buttercup-it "the test spec"
+ (lambda () 23)))
+ (spec (car (buttercup-suite-children buttercup--current-suite))))
+ (expect created :to-be spec)
(expect (buttercup-spec-description spec)
:to-equal
"the test spec")
- [nongnu] elpa/buttercup 8b3cfad 214/340: Update test for new warning capture suppression behavior, (continued)
- [nongnu] elpa/buttercup 8b3cfad 214/340: Update test for new warning capture suppression behavior, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 1567c03 215/340: Add emacs-26.3 to CI config, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 6cf8041 229/340: Update writing-tests.md to describe new spy context structs, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup c720cef 233/340: Merge pull request #146 from DarwinAwardWinner/spy-record-errors, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup b2edd35 235/340: Change: (buttercup-define-matcher-for-binary-function) Add newlines, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 818c150 239/340: docs: Clarify the difference between :var and `let', ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup d8ab09d 244/340: Update documentation for the --pattern option in running-tests.md, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup adba24e 246/340: Bump version: 1.19 → 1.20, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup e7e5d22 248/340: Add an option to immediately abort Buttercup run if a test fails, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup dcc2638 249/340: Revert "Add an option to immediately abort Buttercup run if a test fails", ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 9b30c75 252/340: Make buttercup-x?it and buttercup-suite-add-child return spec,
ELPA Syncer <=
- [nongnu] elpa/buttercup 3734152 251/340: Make buttercup-describe return the created suite object, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 8271c27 254/340: Only update spec state if it is worse or equal, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 966798f 255/340: Correct all docstrings to pass checkdoc, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup b520dcf 257/340: Print test run duration in an apropriate unit, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 1fd0d8b 260/340: Set state pending for skipped specs for correct initial count, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup b298517 262/340: test: Mark some local function arguments as unused, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 8e29f4c 259/340: Extract buttercup--mark-skipped from buttercup-run-discover, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 669ca99 267/340: test: Split make rule test into test-buttercup and test-docs, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 6655f77 269/340: Update test run duration output in buttercup-reporter-batch, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 0e6c09e 271/340: Correct the assume docstring, ELPA Syncer, 2021/12/16