Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I run tests without exporting all the symbols

I have (at least) one package where my main program lives. I have another package for running tests. I :use the package of the main program in the defpackage form of the test package but that only imports the exported symbols. So I can't test all of functions, only the ones I have explicitly exported (the public API). How to I solve this issue?

like image 424
PuercoPop Avatar asked Oct 21 '25 04:10

PuercoPop


1 Answers

You can always refer to internal (un-exported) symbols with a double-colon qualifier:

(package-name::function-name)

You can also import a symbol into your test package (regardless of whether it's been exported from the main package) with import. For instance:

(import 'package-name::function-name)
(fboundp 'function-name)  ;; => t

Here's the CLHS entry on import.

Also, if you haven't read it, I recommend the Programming in the Large: Packages and Symbols chapter from Practical Common Lisp. It doesn't directly address your question, but I mention it because I've found it very helpful regrading packages and symbols in general.

like image 174
jbm Avatar answered Oct 24 '25 04:10

jbm



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!