From 59035c17d08f0999ba96c74d1763eedb0347d11e Mon Sep 17 00:00:00 2001 From: Andrea Corallo Date: Mon, 9 Sep 2019 21:39:03 +0200 Subject: [PATCH] add test for recursive calls --- test/src/comp-test-funcs.el | 6 ++++++ test/src/comp-tests.el | 3 +++ 2 files changed, 9 insertions(+) diff --git a/test/src/comp-test-funcs.el b/test/src/comp-test-funcs.el index dbc90771774..e43db6973b7 100644 --- a/test/src/comp-test-funcs.el +++ b/test/src/comp-test-funcs.el @@ -221,6 +221,12 @@ (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 ;; ;;;;;;;;;;;;;;;;;;;; diff --git a/test/src/comp-tests.el b/test/src/comp-tests.el index 4f4005bea66..16726cb4bbe 100644 --- a/test/src/comp-tests.el +++ b/test/src/comp-tests.el @@ -262,6 +262,9 @@ (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 ;; ;;;;;;;;;;;;;;;;;;;; -- 2.39.5