Add unit tests for lib.functions.take
This commit is contained in:
@@ -27,7 +27,7 @@ each member is STEP distance apart."
|
||||
(loop :for i :from start :to (1- end) :by step
|
||||
:collect i)))
|
||||
|
||||
(fn take (n lst) (-> (fixnum list) list)
|
||||
(fn take (n lst) (-> (fixnum sequence) sequence)
|
||||
"Return the first N elements of LST."
|
||||
(subseq lst 0 n))
|
||||
|
||||
|
||||
@@ -39,3 +39,12 @@
|
||||
(true (null (range 1 1)))
|
||||
(is equal '(1 2 3 4) (range 1 5))
|
||||
(is equal '(-3 -2 -1 0) (range -3 1)))
|
||||
|
||||
(define-test (function-test take)
|
||||
:compile-at :execute
|
||||
(fail (take nil nil))
|
||||
(fail (take 100 nil))
|
||||
(fail (take nil 100))
|
||||
(true (->> (list 1 2 3 4) (take 0) null))
|
||||
(is equal "H" (take 1 "Hello"))
|
||||
(is equal '(1 2) (take 2 '(1 2 3 4 5))))
|
||||
|
||||
Reference in New Issue
Block a user