Commits

certainty  committed 629a74c Draft

massively simplified it

  • Participants
  • Parent commits b28902a
  • Branches simplification

Comments (0)

Files changed (3)

File missbehave-matchers.scm

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Have/Has
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
 (define-syntax has
   (syntax-rules ()
-    ((_ argument +more-arguments ...)
-     (have argument +more-arguments ...))))
-
-(define-syntax have
-  (syntax-rules ()
     ((_ amount procedure-or-sugar)
      (if (procedure? (quote procedure-or-sugar))
          (have-matcher amount procedure-or-sugar (quote procedure-or-sugar))
          (have-matcher amount (quote procedure-or-sugar) (quote procedure-or-sugar))))))
 
+
+
 (define (have-matcher expected-amount procedure-or-sugar procedure-or-sugar-name #!key (compare =))
   (let ((actual-amount #f))
     (matcher
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; raise
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
 (define-syntax raise
   (syntax-rules (error errors with)
     ((_ error)

File missbehave.scm

-; This is the new implementation of missbehave. It is a heavily simplified version of the original code.
-; For the reasons on why i implemented it please refer to:
-; {{link_to_blogpost}
+;; This is the new implementation of missbehave. It is a heavily simplified version of the original code.
+;; For the reasons on why i implemented it please refer to:
+;; {{link_to_blogpost}
 
-; The base library assumes nothing about outputting/handling  failured or succeeded verifications.
-; All it does is provide a protocoll that other parts can hook into to actually do something useful with this information.
+;; The base library assumes nothing about outputting/handling  failured or succeeded verifications.
+;; All it does is provide a protocoll that other parts can hook into to actually do something useful with this information
 
 (define current-failure-notification-receiver (make-parameter (lambda _ #t)))
 (define current-success-notification-receiver (make-parameter (lambda _ #t)))
 ;; for example one might to run them in a sandbox
 ;; or in its own thread
 (define (run-matcher quoted-expr expr complement? matcher)
-  (let* ((result (matcher complement? quoted-expr (force expr)))
-         (failure-message ((if complement? cadr caddr) result)))
+  (let* ((result (matcher complement? quoted-expr expr))
+         (failure-message (if complement? cadr caddr)))
     (if (not (car result))
-        (notify-failure failure-message)
+        (notify-failure (failure-message result))
         (notify-success quoted-expr))))
 
 ;; the matcher protocoll is simple
 ;; 1) complement? - is that in complement context
 ;; 2) quoted-expr - the quoted-expr that shall be checked
 ;; 3) expr        - a promise fore the expression
+
+;; this is the buildin matcher that allows us to run the simplified form
+;; for verify
 (define ((boolean-matcher . args) complement? quoted-expr expr)
   (let ((result (if complement? (not (force expr)) (force expr))))
     (if result

File spec/test.scm

-;; 
-;; %%HEADER%%
-;; 
-
-;(load "./missbehave.scm")
-;(import missbehave)
-(use missbehave missbehave-matchers missbehave-stubs miscmacros)
+(use missbehave)
 
 (define (callee . args) 'called)
 (define (call-it n)
      (it (is > 0))
      (it (is a number))
      (it should (be 42)))
-  
-         
+
+
   (describe "Simple be matchers"
      (it "must be true"
          (expect #t (be true)))
 
 
   (define (numbers ls) ls)
-  
+
   (describe "Have"
     (it "can be used with a collection procedure"
       (expect '(1 2 3) (has 3 numbers)))
   ;;   (it "checks if subject matches regex"
   ;;     (expect "1234" (matches '(: (+ digit))))))
 
-  
 
   (describe "Pending"
      (it "is implicitly pending")
      (it "is explicitly pending"
          (pending)
-         (expect '() (be a number))))         
+         (expect '() (be a number))))
 
   (describe "Procedure expectations"
     (context "Application-count"