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

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

[nongnu] elpa/buttercup fd70ccf 002/340: Specs are now structs.


From: ELPA Syncer
Subject: [nongnu] elpa/buttercup fd70ccf 002/340: Specs are now structs.
Date: Thu, 16 Dec 2021 14:58:53 -0500 (EST)

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

    Specs are now structs.
---
 buttercup.el | 33 ++++++++++++++++++---------------
 1 file changed, 18 insertions(+), 15 deletions(-)

diff --git a/buttercup.el b/buttercup.el
index d146d1f..4e6ad5b 100644
--- a/buttercup.el
+++ b/buttercup.el
@@ -141,8 +141,8 @@ should describe why a negated matcher failed."
     (error
      (cons t (format "Expected %S not to throw an error" function)))))
 
-;;;;;;;;;;
-;;; Suites
+;;;;;;;;;;;;;;;;;;;;
+;;; describe: Suites
 
 (cl-defstruct buttercup-suite
   description
@@ -155,9 +155,6 @@ should describe why a negated matcher failed."
         (append (buttercup-suite-nested parent)
                 (list child))))
 
-;;;;;;;;;;;;
-;;; describe
-
 (defvar buttercup-suites nil
   "The list of all currently defined Buttercup suites.")
 
@@ -184,8 +181,12 @@ form.")
       (setq buttercup-suites (append buttercup-suites
                                      (list buttercup--current-suite))))))
 
-;;;;;;
-;;; it
+;;;;;;;;;;;;;
+;;; Specs: it
+
+(cl-defstruct buttercup-spec
+  description
+  function)
 
 (defmacro it (description &rest body)
   "Define a spec."
@@ -197,8 +198,9 @@ form.")
   (when (not description)
     (error "`it' has to be called from within a `describe' form."))
   (buttercup-suite-add-nested buttercup--current-suite
-                              (cons description
-                                    body-function)))
+                              (make-buttercup-spec
+                               :description description
+                               :function body-function)))
 
 ;; (let* ((buttercup--descriptions (cons description
 ;;                                       buttercup--descriptions))
@@ -244,14 +246,15 @@ form.")
          (indent (make-string (* 2 level) ?\s)))
     (message "%s%s\n" indent (buttercup-suite-description suite))
     (dolist (sub (buttercup-suite-nested suite))
-      (if (buttercup-suite-p sub)
-          (progn
-            (message "")
-            (buttercup-run-suite sub (1+ level)))
+      (cond
+       ((buttercup-suite-p sub)
+        (message "")
+        (buttercup-run-suite sub (1+ level)))
+       ((buttercup-spec-p sub)
         (message "%s%s"
                  (make-string (* 2 (1+ level)) ?\s)
-                 (car sub))
-        (funcall (cdr sub))))
+                 (buttercup-spec-description sub)))
+        (funcall (buttercup-spec-function sub))))
     (message "")))
 
 (defun buttercup-markdown-runner ()



reply via email to

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