public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Paul Jackson <pj@sgi.com>
To: Matt Mackall <mpm@selenic.com>
Cc: akpm@osdl.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 9/8] lib/sort: turn off self-test
Date: Mon, 31 Jan 2005 12:49:57 -0800	[thread overview]
Message-ID: <20050131124957.098ed888.pj@sgi.com> (raw)
In-Reply-To: <20050131170344.GP2891@waste.org>

Matt wrote:
> I actually think that more code
> ought to have such tests, so long as they don't obscure the code in
> question.

If all the little unit tests that had ever been coded for kernel code
were embedded in "#if 0 ... #endif" sections, it _would_ obscure the
code.

To the local maintainer of a file, it's not much of an issue, as they
are actively familiar with what's there and look past the disabled test.
But to the stranger passing through, it's just another three dozen lines
of code that need to be waded through, or another false hit or two on
some wide ranging grep that needs to be filtered out.

Instead, I'd suggest a couple of comments:

 1) Describe this unit test in a comment, such as:

	/*
	 * Nice unit test for this sort: try sorting the array
	 * of 1000 integers constructed with the loop:
	 *	for (i = 0; i < 1000; i ++)
	 *		a[i] = r = (r * 725861) % 6599;
	 * Sort then verify that for each i: a[i] <= a[i+1].
	 */

    Five lines of comment are substantially less intrusive
    than three dozen lines of code.  Both smaller, and even
    in the output of a grep, visually distinct.

 2) Describe whatever it was you stumbled on that's behind
    your comment:

	I ran into a strange regparm-related bug ...

-- 
                  I won't rest till it's the best ...
                  Programmer, Linux Scalability
                  Paul Jackson <pj@sgi.com> 1.650.933.1373, 1.925.600.0401

  reply	other threads:[~2005-01-31 20:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-01-31  7:44 [PATCH 9/8] lib/sort: turn off self-test Matt Mackall
2005-01-31 11:57 ` Paul Jackson
2005-01-31 12:20   ` Andreas Gruenbacher
2005-01-31 17:03   ` Matt Mackall
2005-01-31 20:49     ` Paul Jackson [this message]
2005-02-10  3:28     ` Werner Almesberger
2005-02-10  7:04     ` Pekka Enberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050131124957.098ed888.pj@sgi.com \
    --to=pj@sgi.com \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mpm@selenic.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox