diff options
author | Ludovic Courtès <ludo@gnu.org> | 2012-11-28 16:42:49 +0100 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2012-11-28 16:43:59 +0100 |
commit | c438cd7175540536c3965b4ffea28ae6df7e59e0 (patch) | |
tree | d605cd827451938f46218bb8692d44438cb0ecce /test-suite/tests/eval.test | |
parent | fc32c44995dacb2c3f2fb9d1eafec59c44787c32 (diff) | |
download | guile-c438cd7175540536c3965b4ffea28ae6df7e59e0.tar.gz |
eval: Store docstrings for lambdas.
Fixes <http://bugs.gnu.org/12173>.
Reported by Ian Price <ianprice90@googlemail.com>.
* libguile/memoize.c (MAKMEMO_LAMBDA): New `docstring' parameter. Add
it as the second argument of `SCM_M_LAMBDA'. Update caller.
(memoize)[SCM_M_LAMBDA]: Extract docstring from EXP; when `memoize'
returns, add the docstring to the lambda's arguments.
(unmemoize)[SCM_M_LAMBDA]: Adjust to new argument layout of
`SCM_M_LAMBDA'.
* libguile/eval.c (BOOT_CLOSURE_NUM_REQUIRED_ARGS,
BOOT_CLOSURE_HAS_REST_ARGS, BOOT_CLOSURE_IS_REST,
BOOT_CLOSURE_PARSE_FULL): Adjust to new argument layout of
`SCM_M_LAMBDA'.
* module/ice-9/eval.scm (primitive-eval)[make-general-closure]:
Likewise.
[eval]: When EXP is a lambda, match its docstring; when the docstring
is not #f, add it to the closures procedure properties.
* test-suite/tests/eval.test ("docstrings"): New test prefix.
* libguile/procs.c (sym_documentation): Rename to...
(scm_sym_documentation): ... this. Make it global.
* libguile/procs.h (scm_sym_documentation): New declaration.
Diffstat (limited to 'test-suite/tests/eval.test')
-rw-r--r-- | test-suite/tests/eval.test | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/test-suite/tests/eval.test b/test-suite/tests/eval.test index a5fbfece2..6ab3b8ac8 100644 --- a/test-suite/tests/eval.test +++ b/test-suite/tests/eval.test @@ -428,6 +428,36 @@ (call-with-vm vm thunk)))) ;;; +;;; docstrings +;;; + +(with-test-prefix "docstrings" + + (pass-if-equal "fixed closure" + '("hello" "world") + (map procedure-documentation + (list (eval '(lambda (a b) "hello" (+ a b)) + (current-module)) + (eval '(lambda (a b) "world" (- a b)) + (current-module))))) + + (pass-if-equal "fixed closure with many args" + "So many args." + (procedure-documentation + (eval '(lambda (a b c d e f g h i j k) + "So many args." + (+ a b)) + (current-module)))) + + (pass-if-equal "general closure" + "How general." + (procedure-documentation + (eval '(lambda* (a b #:key k #:rest r) + "How general." + (+ a b)) + (current-module))))) + +;;; ;;; local-eval ;;; |