test/utils.lisp @ 582f7076626b

Change `(values)` to `nil`

SBCL likes when a function just returns `nil` much more.
author Steve Losh <steve@stevelosh.com>
date Sun, 17 Jul 2016 16:59:50 +0000
parents aacf9ee4fddc
children 4abb7eda96cb
(in-package #:bones-test.utils)


;;;; Utils
(defun result= (x y)
  (set-equal (plist-alist x)
             (plist-alist y)
             :test #'equal))

(defun results= (r1 r2)
  (set-equal r1 r2 :test #'result=))


(defmacro should-fail (&body queries)
  `(progn
     ,@(loop :for query :in queries :collect
             `(is (results= nil (query-all ,query))))))

(defmacro should-return (&body queries)
  `(progn
    ,@(loop :for (query . results) :in queries
            :collect
            `(is (results= ',(cond
                               ((equal results '(empty))
                                (list nil))
                               ((equal results '(fail))
                                nil)
                               (t results))
                           (query-all ,query))))))