Sha256: cb096f66c7ffed88630d6585b741e425195ae579aa73a5331019415ffadcca86

Contents?: true

Size: 1.61 KB

Versions: 343

Compression:

Stored size: 1.61 KB

Contents

(ql:quickload "lisp-unit")
#-xlisp-test (load "strain")

(defpackage #:strain-test
  (:use #:common-lisp #:lisp-unit))

(in-package #:strain-test)

(define-test empty-keep
  (assert-equal '() (strain:keep #'under-10-p '())))

(define-test keep-everything
  (assert-equal '(1 2 3) (strain:keep #'under-10-p '(1 2 3))))

(define-test keep-first-last
  (assert-equal '(1 3) (strain:keep #'oddp '(1 2 3))))

(define-test keep-nothing
  (assert-equal '() (strain:keep #'evenp '(1 3 5 7))))

(define-test keep-neither-first-nor-last
  (assert-equal '(2) (strain:keep #'evenp '(1 2 3))))

(define-test keep-strings
  (let ((strs '("apple" "zebra" "banana" "zombies" "cherimoya" "zealot")))
    (assert-equal '("zebra" "zombies" "zealot")
              (strain:keep #'starts-with-z-p strs))))

(define-test empty-discard
  (assert-equal '() (strain:discard #'under-10-p '())))

(define-test discard-everything
  (assert-equal '() (strain:discard #'under-10-p '(1 2 3))))

(define-test discard-first-and-last
  (assert-equal '(2) (strain:discard #'oddp '(1 2 3))))

(define-test discard-nothing
  (assert-equal '(1 3 5 7) (strain:discard #'evenp '(1 3 5 7))))

(define-test discard-neither-first-nor-last
  (assert-equal '(1 3) (strain:discard #'evenp '(1 2 3))))

(define-test discard-strings
  (let ((strs '("apple" "zebra" "banana" "zombies" "cherimoya" "zealot")))
    (assert-equal '("apple" "banana" "cherimoya")
              (strain:discard #'starts-with-z-p strs))))

(defun under-10-p (n) (< n 10))

(defun starts-with-z-p (s) (char= (char s 0) #\z))

#-xlisp-test
(let ((*print-errors* t)
      (*print-failures* t))
  (run-tests :all :strain-test))

Version data entries

343 entries across 343 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/common-lisp/exercises/strain/strain-test.lisp
trackler-2.2.1.179 tracks/common-lisp/exercises/strain/strain-test.lisp
trackler-2.2.1.178 tracks/common-lisp/exercises/strain/strain-test.lisp
trackler-2.2.1.177 tracks/common-lisp/exercises/strain/strain-test.lisp
trackler-2.2.1.176 tracks/common-lisp/exercises/strain/strain-test.lisp
trackler-2.2.1.175 tracks/common-lisp/exercises/strain/strain-test.lisp
trackler-2.2.1.174 tracks/common-lisp/exercises/strain/strain-test.lisp
trackler-2.2.1.173 tracks/common-lisp/exercises/strain/strain-test.lisp
trackler-2.2.1.172 tracks/common-lisp/exercises/strain/strain-test.lisp
trackler-2.2.1.171 tracks/common-lisp/exercises/strain/strain-test.lisp
trackler-2.2.1.170 tracks/common-lisp/exercises/strain/strain-test.lisp
trackler-2.2.1.169 tracks/common-lisp/exercises/strain/strain-test.lisp
trackler-2.2.1.167 tracks/common-lisp/exercises/strain/strain-test.lisp
trackler-2.2.1.166 tracks/common-lisp/exercises/strain/strain-test.lisp
trackler-2.2.1.165 tracks/common-lisp/exercises/strain/strain-test.lisp
trackler-2.2.1.164 tracks/common-lisp/exercises/strain/strain-test.lisp
trackler-2.2.1.163 tracks/common-lisp/exercises/strain/strain-test.lisp
trackler-2.2.1.162 tracks/common-lisp/exercises/strain/strain-test.lisp
trackler-2.2.1.161 tracks/common-lisp/exercises/strain/strain-test.lisp
trackler-2.2.1.160 tracks/common-lisp/exercises/strain/strain-test.lisp