Gentoo Archives: gentoo-dev

From: Rolf Eike Beer <eike@×××××××.de>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] [PATCH 3/5] qmail.eclass: simplify is_prime()
Date: Thu, 12 Aug 2021 15:25:10
Message-Id: 4643426.GXAFRqVoOG@eto.sf-tec.de
In Reply to: Re: [gentoo-dev] [PATCH 3/5] qmail.eclass: simplify is_prime() by Ulrich Mueller
1 Am Donnerstag, 12. August 2021, 13:25:09 CEST schrieb Ulrich Mueller:
2 > >>>>> On Thu, 12 Aug 2021, Rolf Eike Beer wrote:
3 > > -# @FUNCTION: primes
4 > > -# @USAGE: <min> <max>
5 > > +# @FUNCTION: is_prime
6 > > +# @USAGE: <number>
7 > >
8 > > # @DESCRIPTION:
9 > > -# Prints a list of primes between min and max inclusive
10 > > -# Note: this functions gets very slow when used with large numbers.
11 > > -primes() {
12 > > - local min=${1} max=${2}
13 > > - local result= primelist=2 i p
14 > > +# Checks wether a number is a valid prime number for queue split
15 > > +is_prime() {
16 > > + local number=${1} i
17 > > +
18 > > + if [[ ${number} < 7 ]]; then
19 > > + # too small
20 > > + return 0
21 > > + fi
22 >
23 > So e.g. all numbers between 100 and 699 qualify as primes? I doubt that
24 > this is what was intended. :)
25
26 Nope.
27
28 > This function asks for a unit test in eclass/tests/.
29
30 Indeed, that would uncover that it had to be "return 1" above.
31
32 The eclass guide at https://devmanual.gentoo.org/eclass-writing/index.html
33 doesn't mention these tests with any words, not even how to run them.
34
35 Eike

Attachments

File name MIME type
signature.asc application/pgp-signature