1. David Krentzlin
  2. veritas

Commits

omc10  committed f6b8fd7

added vector including

  • Participants
  • Parent commits 2a52082
  • Branches default

Comments (0)

Files changed (2)

File tests/run.scm

View file
               (test "list-including negative (no list)"
                     #t
                     (verification-failure? (verify 2 is (list-including 2))))
+
+              (test "vector-including"
+                    #t
+                    (verification-success? (verify (vector 1 2) is (vector-including 2))))
+              (test "vector-including negative"
+                    #t
+                    (verification-failure? (verify (vector 1 2) is (vector-including 0))))
+              (test "vector-including negative (no vector)"
+                    #t
+                    (verification-failure? (verify 2 is (vector-including 2))))
               (test "none-of"
                     #t
                     (verification-success? (verify 1 is (none-of 4 5 6))))

File veritas-verifiers.scm

View file
   (and (list? subject)
        (every (cut member <> subject) (cons item more-items))))
 
-(define ((vector-including item . more-items) subject) #t)
+(define ((vector-including . args) subject)
+  (and (vector? subject)
+       (let ((subject (vector->list subject)))
+         (every (cut member <> subject) args))))
+
 (define ((hash-table-including item . more-items) subject) #t)
 
 )