From c5584d88b18cedba257bf2958493b31ed62cd9e4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20V=C3=A1zquez?= Date: Thu, 20 Jun 2013 14:25:56 +0200 Subject: [PATCH] Reduce tests --- tests/seq.lisp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/seq.lisp b/tests/seq.lisp index ce1c8d6..a780b1b 100644 --- a/tests/seq.lisp +++ b/tests/seq.lisp @@ -55,3 +55,25 @@ (test (equal (subseq nums 2 4) '(3 4))) ; Test that nums hasn't been altered: SUBSEQ should construct fresh lists (test (equal nums '(1 2 3 4 5)))) + +;;; REDUCE +(test (equal (reduce (lambda (x y) `(+ ,x ,y)) + '(1 2 3 4)) + '(+ (+ (+ 1 2) 3) 4))) + +(test (equal (reduce (lambda (x y) `(+ ,x ,y)) + '(1 2 3 4) + :from-end t) + '(+ 1 (+ 2 (+ 3 4))))) + +(test (equal (reduce #'+ nil) 0)) +(test (equal (reduce #'+ '(1)) 1)) +(test (equal (reduce #'+ nil :initial-value 1) 1)) + +(test (equal (reduce #'+ '() + :key #'1+ + :initial-value 100) + 100)) + +(test (equal (reduce #'+ '(100) :key #'1+) + 101)) -- 1.7.10.4