I want to create a modifier that accepts a dynamic array, like this:
modifier parameterizedTest(Set[] memory sets) {
// ...
}
Where the Set struct is defined like this:
struct Set {
uint256 x;
uint256 y;
uint256 expected;
}
Now, I know that normally one has to use multiple statements to define the array, like this:
Set[] memory sets = new Set[](1);
sets.push(Set(1,2,3));
But is there any way to "shortcut" that approach? Ideally, I would like to pass my arrays declaratively to the modifier, like this:
function testSomething() external parameterizedTest([Set(1,2,3)]) {
// ...
}
I know that the code above does not compile. I wrote it just for demonstrational purposes.
testSomething, because I'm using Foundry. If I did that define an array as an argument, Foundry would fuzz the inputs, whereas I need to use pre-defined values. – Paul Razvan Berg Sep 05 '22 at 12:59