From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Panicz Maciej Godek Newsgroups: gmane.lisp.guile.user Subject: Re: Python-style doctests in Guile (implemented, please comment) Date: Mon, 31 Jul 2017 15:04:08 +0200 Message-ID: References: <87379d7m66.fsf@web.de> <87ini8zs4w.fsf@netris.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1501506318 31293 195.159.176.226 (31 Jul 2017 13:05:18 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 31 Jul 2017 13:05:18 +0000 (UTC) Cc: "guile-user@gnu.org" To: Mark H Weaver Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Mon Jul 31 15:05:14 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 1dcANj-0007jr-EP for guile-user@m.gmane.org; Mon, 31 Jul 2017 15:05:11 +0200 Original-Received: from localhost ([::1]:59473 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dcANp-0001fo-B7 for guile-user@m.gmane.org; Mon, 31 Jul 2017 09:05:17 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:37655) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dcAMr-0001QB-Fb for guile-user@gnu.org; Mon, 31 Jul 2017 09:04:22 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dcAMm-0007pT-TB for guile-user@gnu.org; Mon, 31 Jul 2017 09:04:17 -0400 Original-Received: from mail-wm0-x22d.google.com ([2a00:1450:400c:c09::22d]:38149) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dcAMm-0007mP-Hq for guile-user@gnu.org; Mon, 31 Jul 2017 09:04:12 -0400 Original-Received: by mail-wm0-x22d.google.com with SMTP id m85so169457540wma.1 for ; Mon, 31 Jul 2017 06:04:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=NxBkXqDN0ykf42BVs+RixZStMI0B/KR7mqLHxbSfbJA=; b=npbohXfS1jlMdTXoE5IlwakLrYODcuse0LD+l1DzSfeB3MVdi0m8mamJlGJkvk9xLW FNvA6CZKg37IcGmZX/nHkpro1DS9xUEycjhiGEUTKCbzGNmJXB3r/Sgg+jhEnQ0Prcqa gbfCjTDbUBZ/3PHlINCS6+uDP6eeYNmdoP8I6DH1m+iw0lKrUOcVeN4Nz8BiqveXgdMo 1p+b6ibeZPgs+pB6kYtGWt6uAdkWNS+mXVrhmLeNUPnjn73GdvQmmtY+SeYzSj3OAtNY EgKeXNsXNpoMvpfkK4ZMIf8FMRmD9/TK7QiiJ/Y2iARxOR8YBfPRFzOhWq/4X5zZk1PQ kHYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=NxBkXqDN0ykf42BVs+RixZStMI0B/KR7mqLHxbSfbJA=; b=hVN/rH1HcSJI1n7Lx6xMJA+4tZ3GCOBkQS01RmJdJ4JZdFOQmOoQwikC7LLfYRLtsL MgfC/r5dqrPoHoslx9KC7dE7KoeSYqBcaMzM4gfyWFJC7A8wBrRi79JptaOcr+D2vJO8 SECiVo7xavYMuAmaVGdPeTUOLLWXVapW0jdSOYkBXQViIrBTHm0HwHPJyo7ToTJMA/ro N6AECmW8zQFGbyXPTUhsx+BYeZfDe64kFGS8BviSFyaaRWwU4BidI+w/+y5uv5vxsw/q AkD2pTZ27bwITx2UTfzeuNhtXDP2E3f8hhqhJRJRsLvHA0PrkZNkRWxiHclqE5cFPmav SGRg== X-Gm-Message-State: AIVw110Ak0TX2YHhPHiVtlrCT7B5G9YeY1zcFgs+DC59pNFa4fhKwjvs amsEmzEF31Ny5sX0Cdrz8Cp02ui1Tw== X-Received: by 10.80.221.79 with SMTP id u15mr2796325edk.213.1501506249749; Mon, 31 Jul 2017 06:04:09 -0700 (PDT) Original-Received: by 10.80.179.129 with HTTP; Mon, 31 Jul 2017 06:04:08 -0700 (PDT) In-Reply-To: <87ini8zs4w.fsf@netris.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::22d X-Content-Filtered-By: Mailman/MimeDel 2.1.21 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:14001 Archived-At: 2017-07-31 14:51 GMT+02:00 Mark H Weaver : > Hi Arne, > > Arne Babenhauserheide writes: > > > I implemented doctests in Guile which allow writing SRFI-64 tests > > directly in the docstring. Here=E2=80=99s a minimal example: > > > > > > (import (examples doctests)) > > > > (define (one) > > "(test 'foo > > (test-equal 1 (one)))" > > 1) > > I don't think that tests should go into doc strings, for a couple of > reasons. First, doc strings already have a purpose, and that's for > documentation. While it may sometimes be beneficial to include a few > examples in the documentation, a full test suite does not, IMO, belong > in the doc string. > > The other issue is that this would involve putting code directly into a > quoted string literal, which causes several problems. One has to do > with editor support for S-expressions. For users of Emacs Scheme mode > and/or paredit, it would mean when writing the tests without the editor > support that we are accustomed to. Additionally, if the test code > involve string constants, then the embedded quotes would need to be > escaped with backslashes, and any escaped characters within the strings > would need double-backslashes, etc. Finally, putting code within a > string literal entails a loss of the hygiene that has been so carefully > developed in modern Scheme macro expanders. > > For these reasons, I'm strongly opposed to this style of testing. > > If you want to do something like this, I would suggest instead defining > some macros like 'define-with-tests' that allow you to put the unit > tests together with each definition. > > What do you think? > I agree with Mark, that putting tests inside a string in Lisp is a terrible idea, because Lisp doesn't have Python's shortcommings, i.e. you can quote symbolic structures in Lisp, whereas you can't do that in Python There is no point in trading something better for something worse merely because people from Python (or elsewhere) can't afford this "better". I usually interleave definitions with tests using the "e.g." form, as you can see here, for example: https://github.com/plande/grand-scheme/blob/master/grand/combinatorics.scm (I've recently found that SRFI-78 does a very similar thing, as SRFI-64 is in my view unnecessarily complex, especially if you want your tests to serv= e as examples)