Overview
Please excuse the somewhat long context, which I feel is necessary to establish the need for this ticket.
I run golden tests by reading from a zip file, that has pairs of input and output files. Please note that the following problem will exist even if these in/out files were read from a directory instead of a zip file.
Each individual test is fed by a @MethodSource, that calls the zip utility with two functions, that are invoked for each in/out pair, respectively. Since the order of the in/out files is nondeterministic, the results of these function invocations are saved in a map. The code in question can be seen here.
Here’s where the Arguments API is lacking for non-trivial use cases.
- There’s no way to concat two
Arguments or add an item to an existing Arguments.
- An
Arguments can only be created from an array, not a collection.
- In the above use case, the return type of the in/out functions could be
Arguments, and we would concat the two Arguments, either by append or prepend, based on whether in or out is encountered first. We could also create the Arguments from collections, not arrays. Currently, all of these have to done by first pulling the array out of an Arguments, creating a new one, and copying stuff over.
Original Proposal
- Add a constructor that accepts a
Collection.
- Add a method
append/add/addLast that appends an item to an existing Arguments, and returns a new one.
- Add a method
prepend/addFirst
- Add a method
concat that appends all items of the Arguments parameter to the Arguments it’s called on.
- Add a method
size.
Current Deliverables
Overview
Please excuse the somewhat long context, which I feel is necessary to establish the need for this ticket.
I run golden tests by reading from a zip file, that has pairs of input and output files. Please note that the following problem will exist even if these in/out files were read from a directory instead of a zip file.
Each individual test is fed by a
@MethodSource, that calls the zip utility with two functions, that are invoked for each in/out pair, respectively. Since the order of the in/out files is nondeterministic, the results of these function invocations are saved in a map. The code in question can be seen here.Here’s where the
ArgumentsAPI is lacking for non-trivial use cases.Argumentsor add an item to an existingArguments.Argumentscan only be created from an array, not a collection.Arguments, and we would concat the twoArguments, either by append or prepend, based on whether in or out is encountered first. We could also create theArgumentsfrom collections, not arrays. Currently, all of these have to done by first pulling the array out of anArguments, creating a new one, and copying stuff over.Original Proposal
Collection.append/add/addLastthat appends an item to an existingArguments, and returns a new one.prepend/addFirstconcatthat appends all items of theArgumentsparameter to theArgumentsit’s called on.size.Current Deliverables
static Arguments Arguments.of(List<@Nullable Object>)static Arguments Arguments.arguments(List<@Nullable Object>)static ArgumentSet Arguments.argumentSet(String, List<@Nullable Object>)default List<@Nullable Object> Arguments.toList(), implemented asnew ArrayList<>(List.of(get()))(or similar) so that the returnedListis mutable.