Split the high nesting of BignumModRawConvertRep.generate_function_tests

Pylint complains about the nesting. It's not wrong.

No behavior change.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
Gilles Peskine 2022-12-21 20:18:23 +01:00
parent 636809f2b9
commit 6d40e54db0

View file

@ -131,22 +131,27 @@ class BignumModRawConvertRep(bignum_common.ModOperationCommon,
mod_with_rep = 'mod({})'.format(self.rep.name) mod_with_rep = 'mod({})'.format(self.rep.name)
return base.replace('mod', mod_with_rep, 1) return base.replace('mod', mod_with_rep, 1)
@classmethod
def test_cases_for_values(cls, rep: bignum_common.ModulusRepresentation,
n: str, a: str) -> Iterator[test_case.TestCase]:
for bil in cls.limb_sizes:
test_object = cls(n, a, bits_in_limb=bil)
test_object.set_representation(rep)
#Filters out the duplicate
if rep == bignum_common.ModulusRepresentation.OPT_RED:
test_object.dependencies= []
if bil == 64:
continue
if test_object.is_valid:
yield test_object.create_test_case()
@classmethod @classmethod
def generate_function_tests(cls) -> Iterator[test_case.TestCase]: def generate_function_tests(cls) -> Iterator[test_case.TestCase]:
for rep in bignum_common.ModulusRepresentation.supported_representations(): for rep in bignum_common.ModulusRepresentation.supported_representations():
for n in cls.moduli: for n in cls.moduli:
for a in cls.input_values: for a in cls.input_values:
for bil in cls.limb_sizes: yield from cls.test_cases_for_values(rep, n, a)
test_object = cls(n, a, bits_in_limb=bil)
test_object.set_representation(rep)
#Filters out the duplicate
if rep == bignum_common.ModulusRepresentation.OPT_RED:
test_object.dependencies= []
if bil == 64:
continue
if test_object.is_valid:
yield test_object.create_test_case()
class BignumModRawCanonicalToModulusRep(BignumModRawConvertRep): class BignumModRawCanonicalToModulusRep(BignumModRawConvertRep):
"""Test cases for mpi_mod_raw_canonical_to_modulus_rep.""" """Test cases for mpi_mod_raw_canonical_to_modulus_rep."""