Commits

certainty  committed 8ed7baf

added grouping framework

  • Participants
  • Parent commits 1fa9afc

Comments (0)

Files changed (3)

File examples/console.scm

 (use veritas-console veritas-quickcheck data-generators)
 
 (use-documentation-formatter)
+(use-short-formatter)
 
-;; (verify #t)
+;; adding descriptions
 (verify #t "This is a test")
+
+;; curried predicate
+(verify 3 (is > 3))
+
+;; Diff when strings are compared
+(verify "This is my\nfooo" (is "This is my\nbarbaz"))
+
 (verify (cons 1 2) (is '(1 . 2)))
 
 (let ((the-pair (cons 1 2)))
 (pending "this is my reason"
   (verify 3 (is 2)))
 
+;; quickcheck functionality
 (quickcheck (subj (gen-uint8))
   ;; will probably fail but is reported only once
   (verify subj (is < 100))
   ;; reported only once
   (verify subj (is > 0)))
 
-(verify 3 (is > 3))
-
-(verify "This is my\nfooo" (is "This is my\nbarbaz"))
+;; Grouping
+(group "Root"
+  (verify 3 (is 3))
+  (verify 3 (is 4))
+  (group "Level 1"
+    (verify 3 (is 3))
+    (verify 3 (is 4))
+    (group "Level 2"
+      (verify 3 (is 3) "With inline description")
+      (verify 3 (is 4) "Error inline descritption")
+      (describe "With wrapping description"
+        (verify 3 (is 3)))
+      (describe "Error with wrapping description"
+        (verify 3 (is 4))))))

File reporters/console.scm

     (let* ((failed-count (length failed-verifications))
            (pending-count (length pending-verifications))
            (total-count (+ passed-count failed-count pending-count)))
-      (newline)
       (printf "Total: ~a Passed: ~a Pending: ~a Failed: ~a" total-count passed-count pending-count failed-count)
       (newline)
       (flush-output)))
     (let* ((failed-count (length failed-verifications))
            (pending-count (length pending-verifications))
            (total-count (+ passed-count failed-count pending-count)))
-      (newline)
       (fmt #t (cat
                (fmt-bold (cat "Total: " total-count))
                " "
 
   (on-exit (lambda ()
              (newline)
+             (newline)
              (report-details)
              (newline)
              (report-summary)
      (meta (description: description)
          body0 ...))))
 
+(define current-groups (make-parameter '()))
+
+(define-syntax group
+  (syntax-rules ()
+    ((_ groupname body0 ...)
+     (parameterize ((current-groups (cons groupname (current-groups))))
+       (meta (group: groupname)
+             body0 ...)))))
+
 (define-syntax meta
   (syntax-rules ()
     ((_ (k v ...) body0 ...)