From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Arne Babenhauserheide Newsgroups: gmane.lisp.guile.user Subject: Re: Python-style doctests in Guile (implemented, please comment) Date: Tue, 10 Oct 2017 20:21:00 +0200 Message-ID: <871smaq2l0.fsf@web.de> References: <87379d7m66.fsf@web.de> <87ini8zs4w.fsf@netris.org> <871sowmri4.fsf@web.de> <5980FAF1.8080806@sapo.pt> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" X-Trace: blaine.gmane.org 1507660207 12350 195.159.176.226 (10 Oct 2017 18:30:07 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 10 Oct 2017 18:30:07 +0000 (UTC) Cc: guile-user@gnu.org To: =?utf-8?Q?V=C3=ADtor?= De =?utf-8?Q?Ara=C3=BAjo?= Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Tue Oct 10 20:30:01 2017 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e1zHx-0001v2-V8 for guile-user@m.gmane.org; Tue, 10 Oct 2017 20:29:58 +0200 Original-Received: from localhost ([::1]:36609 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1zI3-0001Bs-Fe for guile-user@m.gmane.org; Tue, 10 Oct 2017 14:30:03 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42801) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1zHI-00019u-2s for guile-user@gnu.org; Tue, 10 Oct 2017 14:29:17 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e1zHE-0001en-0h for guile-user@gnu.org; Tue, 10 Oct 2017 14:29:16 -0400 Original-Received: from mout.web.de ([212.227.17.12]:55966) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e1zHD-0001dO-Lp for guile-user@gnu.org; Tue, 10 Oct 2017 14:29:11 -0400 Original-Received: from fluss ([85.212.89.60]) by smtp.web.de (mrweb101 [213.165.67.124]) with ESMTPSA (Nemesis) id 0M9GVO-1e85PO3ZJW-00Citu; Tue, 10 Oct 2017 20:29:09 +0200 In-reply-to: <5980FAF1.8080806@sapo.pt> X-Provags-ID: V03:K0:oZ2ngAB/WrvM5vKZ9X4rT7DLmCVeF/ovEPeUjufcvuZMLHyULfx vI328B3jf0oLJQWVa5L31Q9Hh7zb0YeopcY+QgD1uLa91GzigTNqmowCwQJEmVWRh3sJ1BU qRB8ohSlVRrn6uOVLoBD/BJAN6y2vK0WLIAEF8mIVRMvWh+egTCofgvJ9OSXXgnFcct8bwp IJE+NnXY6SUeJGEXJyXrw== X-UI-Out-Filterresults: notjunk:1;V01:K0:l8ko6PepJHk=:xNMRyH8+UPLAmAI1pUI5fG +VyJZPmMNEgC8GoE26hUFaKPRD2u4uXSy79UzZuGVvXkY7Y7ymvE4uegczSJCuhyZS8PzCNuo EBDPKpe6gjt9AJLeziN8A0IVeLO/NwUmBgTiNQalOos2/mELdzMu0W+9jpqAHsHdUMdk/0zG6 U6o3lzirlcbRbTxEoi9geCx1BxptyGKYrAPfG0aEPCGALySZAVcNPaerNG1CXHB0abjakAWCg 1WZKK0BlhpRgJqt70g8ym+g/8KkMWNupaop4MkVxT7yms8e6npJWUVi2ezSyKdIP3dZPJAeV1 RXpF29gyGGCL5sGB++HSfQzc2jqFUTp9Pu+fP6nvWYqIYOBqEKrTfhpB2bKuW6RQSNP9AIYe4 wbSJrWcDwXtnn+BxuRxYAmpuFq48flKNrj9ahm0zq6YjriSBB2DTsKnrKhKMWmXrR3c46C3xy ZcQsR3F8cNgbiaSE+Gl5yNHXkNN0bMEUBsbR0K51Y7CHgU6I6TBP9YcNPo1ZWQuW2GHQqpv9a N6ZwKs+Pieve90w0inguZxEnJr99sYxHaycA1tnrXy/o69PWxtqd75CfggBIZIsu1aNqPuPWo gjx86+6w62zazEvKa2J+Yo3b4XcXQPXaKovh6COqNNcxGkDr1XanVo/mTNq5fsT9Vi5d5dBGz gpS8X+zCtnQFMbDSzNZw0FjNfDQsKvYrFbHeW0HBT5gLdRzD2xCxAK2e8CD6Xhrnb5emZJM8H z1Z4y8eV9lNg9FyoxZKTY41B7e1QWR44uc3zR+AETe1tfq6sslYzwfhv0xXrlFLdZm5Ed8b7 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 212.227.17.12 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.org gmane.lisp.guile.user:14202 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi Vitor, I=E2=80=99m sorry for answering so late; your suggestion stuck to my mind a= s a clean and schemish solution for my usecase (thank you!) but it took me quite a while to realize it. V=C3=ADtor De Ara=C3=BAjo writes: > (define (double x) > "Returns twice the value of a given number." > #((examples [(double 5) 10] > [(double 0) 0])) > (* 2 x)) I now implemented this for tests based on srfi-64: https://bitbucket.org/ArneBab/wisp/src/299795dbb3fecea91dcdde480817b36fc45c= cc5f/examples/doctests.scm Here=E2=80=99s the documentation: ;;; doctests --- simple testing by adding procedure-properties with tests. ;;; Usage ;; Add a tests property to a procedure to have simple unit tests. ;; Simple tests: ;; ;; (define (A) ;; #((tests (test-eqv 'A (A)) ;; (test-assert #t))) ;; 'A) ;; ;; Named tests: ;; ;; (define (A) ;; #((tests ('test1 (test-eqv 'A (A)) ;; (test-assert #t)) ;; ('test2 (test-assert #t)))) ;; 'A) ;; ;; Allows for docstrings: ;; ;; (define (A) ;; "returns 'A" ;; #((tests (test-eqv 'A (A)) ;; (test-assert #t))) ;; 'A) ;; For writing the test before the implementation, start with the test and = #f: ;; (define (A) ;; #((tests (test-eqv 'A (A)))) ;; #f) This is what was missing for me to get an elegance in test-driven design which I had been missing till now. And it really feels much more elegant than the stringly doctesting in Python. The output looks like this: %%%% Starting test examples-doctests.scm--doctests-testmod--mytest (Writin= g full log to "examples-doctests.scm--doctests-testmod--mytest.log") # of expected passes 3 %%%% Starting test examples-doctests.scm--doctests-testmod--mytest2 (Writi= ng full log to "examples-doctests.scm--doctests-testmod--mytest2.log") # of expected passes 4 %%%% Starting test examples-doctests.scm--subtract (Writing full log to "e= xamples-doctests.scm--subtract.log") # of expected passes 5 Now there=E2=80=99s one first question: How should I call it? :-) Currently the modules is (examples doctests). Do you have a better idea than "doctests"? Best wishes, Arne =2D-=20 Unpolitisch sein hei=C3=9Ft politisch sein ohne es zu merken --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEE801qEjXQSQPNItXAE++NRSQDw+sFAlndEW8ACgkQE++NRSQD w+vfTw/9F9bnNK5D9kjMIvLNndW0mxUG+C0QgvCf4NXxvgDZtDnRx2z3nPIIssQL KwpbRz4mLBNmzE+3K7KR6T0NXZ3EvqCBlnFf3Dm7AjbqEEOJ9QttRpiM/Jkx/sce JeraWOqwGETR5wMlVJoIQbOCQFxjpYTQu98RDQdiAUWpKe+EfR7jKVxfEPu9stxR s3AwcnBF/MUbWIzpbetfo0jOHymPPTCUCMu25EvGB+OiW+OwKXZ8YQufHvwMGuEo Siu1r6d/lccHGwXo83LQP2Mm+V3lEHwBwnbnQN41+yIFOKBXUXT6OXtaQ5+A/sJ5 MdtMUYkAp8C92g6fLxIwYApKXu58LrE40krsodUhbrqdOYOaFPMDeXH3pAqFq7ft 7Pk8vlDHn/M0z3bc2On9kX5kd/RqYv8JWyy7ACICj5KxutpkziMeAU9oJSaMRqWV +2twZF18buY1bULPmJeWFnh6YafH7jjKMcfc+kFablCBSu9fap1Xg63IX4n3gqLe cfkDvd66Ka3mzfwiesvoaBeMqtfdAZRdq/6znDwqqqJWdxafAgbM04c33UO9lOfG mKlR7nIKINt9YWZGObZ+Elk+xx3sZmq0n7bFse1niACUXXPSjH4no72h57H81hyc 658PCHt07tVW9Yx6jYvgBfFCqArkOXceCXINacyKiXrffw5TDks= =XgXq -----END PGP SIGNATURE----- --=-=-=--