diff options
author | Colin Okay <colin@cicadas.surf> | 2022-09-09 10:21:20 -0500 |
---|---|---|
committer | Colin Okay <colin@cicadas.surf> | 2022-09-09 10:21:20 -0500 |
commit | 4a6999e8411ee4c66fad60b8687843676010f192 (patch) | |
tree | 46ee25c5022ec8b53484fa5bbc4b39bd515ea308 /gtwiwtg-test.lisp | |
parent | 25e08d89e3553b46e247fd91dfaa2bd6eb11ac79 (diff) |
Refactor: combination functions use testiere
Diffstat (limited to 'gtwiwtg-test.lisp')
-rw-r--r-- | gtwiwtg-test.lisp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/gtwiwtg-test.lisp b/gtwiwtg-test.lisp index 3fd3781..6ca4c97 100644 --- a/gtwiwtg-test.lisp +++ b/gtwiwtg-test.lisp @@ -4,6 +4,54 @@ (in-package :gtwiwtg-test) +(defun test-resumables () + (let ((foobar + (make-resumable! (range)))) + (take 10 foobar) + (setf foobar (resume! foobar)) + (assert (equal (take 10 foobar) + '(10 11 12 13 14 15 16 17 18 19))))) + +(defun test-inflate! () + (let* ((keys (seq '(:name :occupation :hobbies))) + (vals (seq '("Buckaroo Banzai" + "Rocker" + ("Neuroscience" "Particle Physics" "Piloting Fighter Jets"))))) + (assert + (equal (collect (inflate! #'seq (zip! keys vals))) + '(:name "Buckaroo Banzai" + :occupation "Rocker" + :hobbies ("Neuroscience" "Particle Physics" "Piloting Fighter Jets")))))) + +(defun test-concat! () + (equal + '(1 2 3 a b c :e :f :g) + (collect (concat! (range :from 1 :to 4) + (seq '(a b c)) + (seq '(:e :f :g)))))) + +(defun test-merge! () + (assert (equal + '(-10 -4 0 1 2 2 3 4 6 8 8 14 20 26) + (collect + (merge! #'< + (times 4) + (range :from 4 :to 10 :by 2) + (range :from -10 :to 28 :by 6)))))) + +(defun test-intersperse! () + (assert + (equal + '(:NAME "buckaroo banzai" :JOB "rocker" :HOBBIES + ("neuroscience" "particle physics" "flying fighter jets")) + (collect + (intersperse! (seq '(:name :job :hobbies)) + (seq '("buckaroo banzai" + "rocker" + ("neuroscience" + "particle physics" + "flying fighter jets")))))))) + (defun gtwiwtg::test-collect () (assert (equal '(1 2 3 4) (collect (range :from 1 :to 4 :inclusive t)))) (assert (equal '(1 2 3 4) (collect (range :from 1 :to 5)))) |