* Doctest for guile
@ 2013-09-11 15:03 Dmitry Bogatov
2013-09-17 17:53 ` Andy Wingo
2013-09-17 18:45 ` Ian Price
0 siblings, 2 replies; 5+ messages in thread
From: Dmitry Bogatov @ 2013-09-11 15:03 UTC (permalink / raw)
To: guile-user@gnu.org
[-- Attachment #1.1: Type: text/plain, Size: 1156 bytes --]
Hello!
I am glad to offer implementation of doctest in Guile --- way to declare
and check tests in function docstring. In most simple way, if in
docstring you write following:
+++ (foo 1 2 3)
--- 6
doctests will check if it is really so. I belive it encourage writing
more modular, generic and pure function. Also, such tests helps to
understand function behavior on corner cases.
This is just proof-of-concept, that offer following:
+ test of multiple values
+ testing of not-exported functions.
You can just download attached archive(I belive it small enough to not
bother with ftp) and do following:
$ tar xf doctest.tar.gz
$ cd doctest
$ export GUILE_LOAD_PATH=$PWD
$ guile doctest.scm '(foo)'
## Two successful tests, one failure
## If no modules specified, doctest tests itself
$ guile doctest.scm
But much more is todo:
+ contollable verbosity
+ exit status on failed tests
+ shortcut for predicates
+ it crashes on input like this:
+++ (foo 1 2 3
--- 6
+ there is no way to say that test should throw
+ Your ideas?
I it will be found useful enough, I will gladly work on patch to integrate
doctest in Guile guild script.
[-- Attachment #1.2: Tarball of doctest sources --]
[-- Type: application/octet-stream, Size: 3436 bytes --]
[-- Attachment #1.3: Type: text/plain, Size: 242 bytes --]
--
Best regards, Dmitry Bogatov <KAction@gnu.org>,
Free Software supporter and netiquette guardian.
git clone git://kaction.name/rc-files.git --depth 1
GPG: 54B7F00D
Html mail and proprietary format attachments are forwarded to /dev/null.
[-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Doctest for guile
2013-09-11 15:03 Doctest for guile Dmitry Bogatov
@ 2013-09-17 17:53 ` Andy Wingo
2013-09-17 18:45 ` Dmitry Bogatov
2013-09-17 18:45 ` Ian Price
1 sibling, 1 reply; 5+ messages in thread
From: Andy Wingo @ 2013-09-17 17:53 UTC (permalink / raw)
To: Dmitry Bogatov; +Cc: guile-user@gnu.org
On Wed 11 Sep 2013 17:03, Dmitry Bogatov <KAction@gnu.org> writes:
> $ guile doctest.scm '(foo)'
Neat!
> + Your ideas?
>
> I it will be found useful enough, I will gladly work on patch to integrate
> doctest in Guile guild script.
I was going to write exactly this! "guild doctest '(foo)'" sounds
sensible to me.
Note also that the compiler will residualize other properties in
addition to docstrings. They are taken from pairs in a static vector in
head position. Hacky, right?
scheme@(guile-user)> (define (foo) #((foo . bar) (baz . qux)) 1)
scheme@(guile-user)> (procedure-properties foo)
$3 = ((arity 0 0 #f) (name . foo) (foo . bar) (baz . qux))
They don't propagate to the interpreter but that can be fixed. Anyway
it's possible to associate some kind of test property with test. If
that's useful to you, anyway.
Cheers,
Andy
--
http://wingolog.org/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Doctest for guile
2013-09-17 17:53 ` Andy Wingo
@ 2013-09-17 18:45 ` Dmitry Bogatov
2013-09-17 19:33 ` Andy Wingo
0 siblings, 1 reply; 5+ messages in thread
From: Dmitry Bogatov @ 2013-09-17 18:45 UTC (permalink / raw)
To: Andy Wingo; +Cc: guile-user@gnu.org
[-- Attachment #1: Type: text/plain, Size: 1077 bytes --]
Andy Wingo <wingo@pobox.com> writes:
>> I it will be found useful enough, I will gladly work on patch to integrate
>> doctest in Guile guild script.
>
> I was going to write exactly this! "guild doctest '(foo)'" sounds
> sensible to me.
>
> Note also that the compiler will residualize other properties in
> addition to docstrings. They are taken from pairs in a static vector in
> head position. Hacky, right?
>
> scheme@(guile-user)> (define (foo) #((foo . bar) (baz . qux)) 1)
> scheme@(guile-user)> (procedure-properties foo)
> $3 = ((arity 0 0 #f) (name . foo) (foo . bar) (baz . qux))
It is intresting, but just now I see no use for it. In face, it seems my
Guile saves less information about function, that your:
$2 = ((name . foo) (foo . bar) (baz . qux))
As you can see, I am missing arity. Is it git patch?
--
Best regards, Dmitry Bogatov <KAction@gnu.org>,
Free Software supporter and netiquette guardian.
git clone git://kaction.name/rc-files.git --depth 1
GPG: 54B7F00D
Html mail and proprietary format attachments are forwarded to /dev/null.
[-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Doctest for guile
2013-09-11 15:03 Doctest for guile Dmitry Bogatov
2013-09-17 17:53 ` Andy Wingo
@ 2013-09-17 18:45 ` Ian Price
1 sibling, 0 replies; 5+ messages in thread
From: Ian Price @ 2013-09-17 18:45 UTC (permalink / raw)
To: Dmitry Bogatov; +Cc: guile-user@gnu.org
Dmitry Bogatov <KAction@gnu.org> writes:
> Hello!
> I am glad to offer implementation of doctest in Guile --- way to declare
> and check tests in function docstring. In most simple way, if in
> docstring you write following:
>
> +++ (foo 1 2 3)
> --- 6
I have to admit, I really don't like these sorts of modules. Automatic
checking of an example in a docstring is fine, but putting all the tests
in a docstring makes the docstring too big to be useful, and you lose
any compile warning time warnings guile can give you on the code.
Just my 2¢, but glad it works for you.
--
Ian Price -- shift-reset.com
"Programming is like pinball. The reward for doing it well is
the opportunity to do it again" - from "The Wizardy Compiled"
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Doctest for guile
2013-09-17 18:45 ` Dmitry Bogatov
@ 2013-09-17 19:33 ` Andy Wingo
0 siblings, 0 replies; 5+ messages in thread
From: Andy Wingo @ 2013-09-17 19:33 UTC (permalink / raw)
To: Dmitry Bogatov; +Cc: guile-user@gnu.org
On Tue 17 Sep 2013 20:45, Dmitry Bogatov <KAction@gnu.org> writes:
> $2 = ((name . foo) (foo . bar) (baz . qux))
> As you can see, I am missing arity. Is it git patch?
Probably you're using master. I think arity is not a property there,
but instead accessed using other accessors.
Regards,
Andy
--
http://wingolog.org/
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-09-17 19:33 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-11 15:03 Doctest for guile Dmitry Bogatov
2013-09-17 17:53 ` Andy Wingo
2013-09-17 18:45 ` Dmitry Bogatov
2013-09-17 19:33 ` Andy Wingo
2013-09-17 18:45 ` Ian Price
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).