clunit icon indicating copy to clipboard operation
clunit copied to clipboard

Inside let forms

Open digikar99 opened this issue 6 years ago • 2 comments

The following does not work:

> (flet ((foo () 5)) (deftest test () (assert-equalp 5 (foo)))) ; looks for (foo) in global env
> (let ((a 4)) (deftest test () (assert-equalp a 4))) ; same issue - a in global environment

Is this a bad practice? This is an "issue" in lisp-unit as well.

digikar99 avatar Jul 21 '19 07:07 digikar99

Hi!

I think you have to use fixtures for this to works:

(asdf:make :clunit)

(in-package :clunit)

(defsuite foo ())

(deftest bar (foo)
  (assert-true (= 5 (+ a 1))))

(deffixture foo (@body)
  (let ((a 4))
    @body))

cage2 avatar Aug 07 '20 17:08 cage2

Hi!

FWIW clunit2 will accept your code. :)

Bye! C.

cage2 avatar Jun 17 '21 16:06 cage2