-
-
Couldn't load subscription status.
- Fork 1.6k
Description
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
Argumentsor add an item to an existingArguments. - An
Argumentscan 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 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
- Add a constructor that accepts a
Collection. - Add a method
append/add/addLastthat appends an item to an existingArguments, and returns a new one. - Add a method
prepend/addFirst - Add a method
concatthat appends all items of theArgumentsparameter to theArgumentsit’s called on. - Add a method
size.
Current Deliverables
- Add
static Arguments Arguments.of(List<@Nullable Object>) - Add
static Arguments Arguments.arguments(List<@Nullable Object>) - Add
static ArgumentSet Arguments.argumentSet(String, List<@Nullable Object>) - Add
default List<@Nullable Object> Arguments.toList(), implemented asnew ArrayList<>(List.of(get()))(or similar) so that the returnedListis mutable.