Commits

Anonymous committed 2a52082

more tests for the is-matcher

Comments (0)

Files changed (3)

reporters/memory.scm

     (set! *failure-notifications* (list))
     (set! *pending-notifications* (list)))
 
-  (define ((make-appender binding) result)
-    (set! binding (cons result binding)))
 
-  (current-success-notification-receiver (make-appender *success-notifications*))
-  (current-failure-notification-receiver (make-appender *failure-notifications*))
-  (current-pending-notification-receiver (make-appender *pending-notifications*))
+  (current-success-notification-receiver
+   (lambda (result)
+     (set! *success-notifications* (cons result *success-notifications*))))
 
-)
+  (current-failure-notification-receiver
+   (lambda (result)
+     (set! *failure-notifications* (cons result *failure-notifications*))))
+
+  (current-pending-notification-receiver
+   (lambda (result)
+     (set! *pending-notifications* (cons result *pending-notifications*))))
+
+  )
-(use test)
-(load "../veritas")
-(load "../veritas-verifiers")
+(use test veritas veritas-verifiers veritas-memory-reporter)
+
 
 (define *protocol* (list))
 
        (set! *protocol* (list))
        code ...))))
 
+(define-syntax with-protocol*
+  (syntax-rules ()
+    ((_ code ...)
+     (begin
+       (reset-memory-reporter!)
+       code ...))))
+
+
 (test-group "verify"
-  (test "invokation of success notifier" #t
-    (with-protocol
-      (verify #t)
-      (verification-success? (car *protocol*))))
+  (test "invokation of success notifier"
+        #t
+        (with-protocol*
+          (verify #t)
+          (verification-success? (car *success-notifications*))))
+
   (test "invokation of failure notifier" #t
-    (with-protocol
+    (with-protocol*
       (verify #f)
-      (verification-failure? (car *protocol*)))))
+      (verification-failure? (car *failure-notifications*)))))
 
 (test-group "falsify"
   (test "invokation of failure notifier" #t
-    (with-protocol
+    (with-protocol*
       (falsify #t)
-      (verification-failure? (car *protocol*))))
+      (verification-failure? (car *failure-notifications*))))
+
   (test "invokation of success notifier" #t
-    (with-protocol
+    (with-protocol*
       (falsify #f)
-      (verification-success? (car *protocol*)))))
+      (verification-success? (car *success-notifications*)))))
 
 (test-group "verify-every")
 
 (test-group "pending"
             (test "invokation of pending notifier"
                   pending:
-                  (with-protocol
+                  (with-protocol*
                    (pending
                     (verify pending:)
-                    (car *protocol*))))
+                    (car *pending-notifications*))))
             (test "it doesn't run the contained tests"
-                  '(#f)
-                  (with-protocol
+                  '()
+                  (with-protocol*
                    (pending
-                    (verify #f)
-                    *protocol*))))
+                    (verify (error "test"))
+                    *success-notifications*))))
 
 (test-group "describe")
 
                     (verification-success? (verify #t is true)))
               (test "with false"
                     #t
-                    (verification-success? (verify #f is false)))))
+                    (verification-success? (verify #f is false)))
+              (test "list-including"
+                    #t
+                    (verification-success? (verify (list 1 2) is (list-including 2))))
+              (test "list-including negative"
+                    #t
+                    (verification-failure? (verify (list 1 2) is (list-including 0))))
+              (test "list-including negative (no list)"
+                    #t
+                    (verification-failure? (verify 2 is (list-including 2))))
+              (test "none-of"
+                    #t
+                    (verification-success? (verify 1 is (none-of 4 5 6))))
+              (test "none-of negative"
+                    #t
+                    (verification-failure? (verify 1 is (none-of 1 5 6))))
+              (test "any-of"
+                    #t
+                    (verification-success? (verify 1 is (any-of 1 2 3))))
+              (test "any-of negative"
+                    #t
+                    (verification-failure? (verify 1 is (any-of 0))))))
 (compile -s -d0 -O3 veritas-verifiers.scm -j veritas-verifiers)
 (compile -s -d0 -O3 veritas-verifiers.import.scm)
 
-(compile -s -d0 -O3 reporters/memory.scm -j veritas-memory-reporter)
+(compile -s -d0 -O3 reporters/memory.scm -j veritas-memory-reporter -o veritas-memory-reporter.so)
 (compile -s -d0 -O3 veritas-memory-reporter.import.scm)
 
 (install-extension
   'veritas-verifiers
   '("veritas-verifiers.import.so" "veritas-verifiers.so")
   `((version ,version)))
+
+
+(install-extension
+  'veritas-memory-reporter
+  '("veritas-memory-reporter.import.so" "veritas-memory-reporter.so")
+  `((version ,version)))