emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/buttercup 0c5cc32 057/340: The buttercup-suites-total-spec


From: ELPA Syncer
Subject: [nongnu] elpa/buttercup 0c5cc32 057/340: The buttercup-suites-total-specs-defined function.
Date: Thu, 16 Dec 2021 14:59:04 -0500 (EST)

branch: elpa/buttercup
commit 0c5cc3251442d69b1d7edcb443120ad09451e698
Author: Jorgen Schaefer <contact@jorgenschaefer.de>
Commit: Jorgen Schaefer <contact@jorgenschaefer.de>

    The buttercup-suites-total-specs-defined function.
---
 buttercup-test.el | 21 +++++++++++++++++++--
 buttercup.el      | 22 ++++++++++++++++++++--
 2 files changed, 39 insertions(+), 4 deletions(-)

diff --git a/buttercup-test.el b/buttercup-test.el
index 22b750c..d27bdf2 100644
--- a/buttercup-test.el
+++ b/buttercup-test.el
@@ -133,8 +133,8 @@
 
 ;; Are tested in README.md
 
-;;;;;;;;;;;;;;;;;;;;
-;;; Suites: describe
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; Suite and spec data structures
 
 (describe "The `buttercup-suite-add-child' function"
   (it "should add an element at the end of the list"
@@ -194,6 +194,23 @@
               :to-equal
               (list parent grandparent)))))
 
+(describe "The `buttercup-suites-total-specs-defined' function"
+  (it "should return the number of specs in a list of suites"
+    (let ((su1 (make-buttercup-suite :description "su1"))
+          (su2 (make-buttercup-suite :description "su2"))
+          (sp1 (make-buttercup-spec :description "sp1"))
+          (sp2 (make-buttercup-spec :description "sp2")))
+      (buttercup-suite-add-child su1 su2)
+      (buttercup-suite-add-child su1 sp1)
+      (buttercup-suite-add-child su2 sp2)
+
+      (expect (buttercup-suites-total-specs-defined (list su1))
+              :to-equal
+              2))))
+
+;;;;;;;;;;;;;;;;;;;;
+;;; Suites: describe
+
 (describe "The `describe' macro"
   (it "should expand to a simple call to the describe function"
     (expect (macroexpand '(describe "description" (+ 1 1)))
diff --git a/buttercup.el b/buttercup.el
index 2791e6b..a81ea6d 100644
--- a/buttercup.el
+++ b/buttercup.el
@@ -211,8 +211,8 @@ MATCHER is either a matcher defined with
       (t
        (cons t (format "Expected %S not to throw an error" function)))))))
 
-;;;;;;;;;;;;;;;;;;;;
-;;; Suites: describe
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; Suite and spec data structures
 
 (cl-defstruct buttercup-suite
   description
@@ -255,6 +255,24 @@ MATCHER is either a matcher defined with
             (buttercup-suite-parents (buttercup-spec-parent spec)))
     nil))
 
+(defun buttercup-suites-total-specs-defined (suite-list)
+  "Return the number of specs defined in all suites in SUITE-LIST."
+  (let ((nspecs 0))
+    (dolist (suite suite-list)
+      (setq nspecs (+ nspecs
+                      (buttercup--total-specs-defined suite))))
+    nspecs))
+
+(defun buttercup--total-specs-defined (suite-or-spec)
+  "Return the number of specs defined in SUITE-OR-SPEC and its children."
+  (if (buttercup-spec-p suite-or-spec)
+      1
+    (apply #'+ (mapcar #'buttercup--total-specs-defined
+                       (buttercup-suite-children suite-or-spec)))))
+
+;;;;;;;;;;;;;;;;;;;;
+;;; Suites: describe
+
 (defvar buttercup-suites nil
   "The list of all currently defined Buttercup suites.")
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]