6dbc64f70f9b

Add list tests
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Sun, 17 Jun 2018 17:16:25 -0700
parents 7db631c1cf60
children 57bdaf80a448
branches/tags (none)
files losh.asd test/lists.lisp

Changes

--- a/losh.asd	Sun Jun 17 17:10:27 2018 -0700
+++ b/losh.asd	Sun Jun 17 17:16:25 2018 -0700
@@ -74,6 +74,7 @@
                 :components ((:file "package")
                              (:file "base")
                              (:file "arrays")
+                             (:file "lists")
                              (:file "control-flow"))))
 
   :perform (asdf:test-op (op system)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/lists.lisp	Sun Jun 17 17:16:25 2018 -0700
@@ -0,0 +1,22 @@
+(in-package :losh.test)
+
+(define-test somelist
+  (is (equal '(a b c d)
+             (somelist (lambda (l)
+                         (if (eq (car l) 'a)
+                           l
+                           nil))
+                       '(a b c d))))
+  (is (equal '(c d)
+             (somelist (lambda (l)
+                         (if (eq (car l) 'c)
+                           l
+                           nil))
+                       '(a b c d))))
+  (is (equal 6
+             (somelist (lambda (l1 l2)
+                         (if (eq (car l1) (car l2))
+                           (+ (length l1) (length l2))
+                           nil))
+                       '(a b c d e)
+                       '(e d c b a)))))