Bignum tests: add support for filtering
Sometimes we don't want all possible combinations of the input data and sometimes not all combinations make sense. We are adding a convenient way to decide on a case by case basis. Now child classes only need to implement the is_valid method and the invalid cases will be filtered out automatically. Signed-off-by: Janos Follath <janos.follath@arm.com>
This commit is contained in:
parent
1921fd585c
commit
939621f8ed
1 changed files with 16 additions and 7 deletions
|
@ -172,6 +172,10 @@ class OperationCommon(test_data_generation.BaseTest):
|
|||
)
|
||||
return super().description()
|
||||
|
||||
@property
|
||||
def is_valid(self) -> bool:
|
||||
return True
|
||||
|
||||
@abstractmethod
|
||||
def result(self) -> List[str]:
|
||||
"""Get the result of the operation.
|
||||
|
@ -204,13 +208,18 @@ class OperationCommon(test_data_generation.BaseTest):
|
|||
raise ValueError("Unknown input style!")
|
||||
if cls.arity not in cls.arities:
|
||||
raise ValueError("Unsupported number of operands!")
|
||||
for a_value, b_value in cls.get_value_pairs():
|
||||
if cls.input_style == "arch_split":
|
||||
for bil in cls.limb_sizes:
|
||||
yield cls(a_value, b_value,
|
||||
bits_in_limb=bil).create_test_case()
|
||||
else:
|
||||
yield cls(a_value, b_value).create_test_case()
|
||||
if cls.input_style == "arch_split":
|
||||
test_objects = (cls(a_value, b_value, bits_in_limb=bil)
|
||||
for a_value, b_value in cls.get_value_pairs()
|
||||
for bil in cls.limb_sizes)
|
||||
else:
|
||||
test_objects = (cls(a_value, b_value) for
|
||||
a_value, b_value in cls.get_value_pairs())
|
||||
yield from (valid_test_object.create_test_case()
|
||||
for valid_test_object in filter(
|
||||
lambda test_object: test_object.is_valid,
|
||||
test_objects
|
||||
))
|
||||
|
||||
|
||||
class ModOperationCommon(OperationCommon):
|
||||
|
|
Loading…
Reference in a new issue