All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michał Kiedrowicz" <michal.kiedrowicz@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, Jeff King <peff@peff.net>
Subject: Re: [PATCH] tests: Introduce test_seq
Date: Sat, 4 Aug 2012 10:14:03 +0200	[thread overview]
Message-ID: <20120804101403.10ad79b5@gmail.com> (raw)
In-Reply-To: <7vfw83a7t5.fsf@alter.siamese.dyndns.org>

Junio C Hamano <gitster@pobox.com> wrote:

> Tentatively I'll queue this one on top, but I am tempted to squash
> this in before merging the topic down.
> 
> -- >8 --
> Subject: [PATCH] fixup! tests: Introduce test_seq
> 
> Complex chains of && and || are harder to read when used as
> replacement for if/else statements, but it is easy to rewrite it
> with a case/esac in this case.

I just copied it from test_expect_success, but yeah, case/esac is
clearer.

> 
> Avoid using unnecessary variables $first and $last.
> 
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> ---
>  t/test-lib-functions.sh | 13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
> index c8b4ae3..7dc70eb 100644
> --- a/t/test-lib-functions.sh
> +++ b/t/test-lib-functions.sh
> @@ -532,7 +532,7 @@ test_cmp() {
>  
>  # Print a sequence of numbers or letters in increasing order.  This is
>  # similar to GNU seq(1), but the latter might not be available
> -# everywhere.  It may be used like:
> +# everywhere (and does not do letters).  It may be used like:
>  #
>  #	for i in `test_seq 100`; do
>  #		for j in `test_seq 10 20`; do
> @@ -543,11 +543,12 @@ test_cmp() {
>  #	done
>  
>  test_seq () {
> -	test $# = 2 && { first=$1; shift; } || first=1
> -	test $# = 1 ||
> -	error "bug in the test script: not 1 or 2 parameters to test_seq"
> -	last=$1
> -	"$PERL_PATH" -le 'print for "$ARGV[0]".."$ARGV[1]"' "$first" "$last"
> +	case $# in
> +	1)	set 1 "$@" ;;
> +	2)	;;
> +	*)	error "bug in the test script: not 1 or 2 parameters to test_seq" ;;
> +	esac
> +	"$PERL_PATH" -le 'print for $ARGV[0]..$ARGV[1]' "$@"
>  }
>  
>  # This function can be used to schedule some commands to be run

  reply	other threads:[~2012-08-04  8:14 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-02 21:11 [PATCH] Fix 'No newline...' annotation in rewrite diffs Adam Butcher
2012-08-02 21:33 ` Jeff King
2012-08-02 21:52   ` Junio C Hamano
2012-08-02 22:14     ` Jeff King
2012-08-03  7:49       ` Michał Kiedrowicz
2012-08-03 16:02         ` Jeff King
2012-08-03 16:46           ` Junio C Hamano
2012-08-03 17:00             ` Jeff King
2012-08-03 19:57           ` [PATCH] tests: Introduce test_seq Michał Kiedrowicz
2012-08-03 20:02             ` Jeff King
2012-08-03 20:53               ` Junio C Hamano
2012-08-03 22:02                 ` Jeff King
2012-08-03 22:09                 ` Michał Kiedrowicz
2012-08-04 16:38                   ` Johannes Sixt
2012-08-04 23:05                     ` Junio C Hamano
2012-08-06 17:52                     ` Michał Kiedrowicz
2012-08-06 20:16                     ` Jeff King
2012-08-03 22:21                 ` Michał Kiedrowicz
2012-08-03 22:48                   ` Junio C Hamano
2012-08-03 23:08                     ` Jeff King
2012-08-03 23:12                   ` Junio C Hamano
2012-08-04  8:14                     ` Michał Kiedrowicz [this message]
2012-08-04 22:10                       ` Adam Butcher
2012-08-03 20:04           ` Michał Kiedrowicz
2012-08-03 20:07             ` Jeff King
2012-08-03 20:12               ` Michał Kiedrowicz
2012-08-03 20:38                 ` Michał Kiedrowicz
2012-08-03 20:41                   ` Jeff King
2012-08-02 22:22   ` [PATCH] Fix 'No newline...' annotation in rewrite diffs Adam Butcher
2012-08-02 22:00 ` Junio C Hamano
2012-08-02 22:58   ` Adam Butcher
2012-08-04 21:07     ` Adam Butcher
2012-08-05  1:26       ` Junio C Hamano
2012-08-05  7:06         ` [PATCH] Fix '\ No " Adam Butcher

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=20120804101403.10ad79b5@gmail.com \
    --to=michal.kiedrowicz@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=peff@peff.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.