]> git.eshelyaron.com Git - emacs.git/commitdiff
add test for recursive calls
authorAndrea Corallo <akrl@sdf.org>
Mon, 9 Sep 2019 19:39:03 +0000 (21:39 +0200)
committerAndrea Corallo <akrl@sdf.org>
Wed, 1 Jan 2020 10:37:47 +0000 (11:37 +0100)
test/src/comp-test-funcs.el
test/src/comp-tests.el

index dbc90771774b3e7e093ac8a69553f1b013229178..e43db6973b79e1e1fca28209946988e217b6d270 100644 (file)
 (defun comp-tests-lambda-return-f ()
   (lambda (x) (1+ x)))
 
+(defun comp-tests-fib-f (n)
+  (cond ((= n 0) 0)
+       ((= n 1) 1)
+       (t (+ (comp-tests-fib-f (- n 1))
+             (comp-tests-fib-f (- n 2))))))
+
 ;;;;;;;;;;;;;;;;;;;;
 ;; Tromey's tests ;;
 ;;;;;;;;;;;;;;;;;;;;
index 4f4005bea66df46a9d33e05b3bc8fe9e686a54ac..16726cb4bbee2f5888f30cf9b70ece1e2f3dd234 100644 (file)
 (ert-deftest comp-tests-lambda-return ()
   (should (= (funcall (comp-tests-lambda-return-f) 3) 4)))
 
+(ert-deftest comp-tests-recursive ()
+  (should (= (comp-tests-fib-f 10) 55)))
+
 ;;;;;;;;;;;;;;;;;;;;
 ;; Tromey's tests ;;
 ;;;;;;;;;;;;;;;;;;;;