sageserpent-open / americium

Generation of test case data for Scala and Java, in the spirit of QuickCheck. When your test fails, it gives you a minimised failing test case and a way of reproducing the failure immediately.
MIT License
15 stars 1 forks source link

More fluent syntax for building strings. #59

Open sageserpent-open opened 1 year ago

sageserpent-open commented 1 year ago

Currently, one builds a Trials<String> via something like this:

api().characters('a', 'z').collections(Builder::stringBuilder).

That is a bit prolix: it would be nicer to write:

api.characters('a', 'z').strings() instead, likewise collectionsOfSize should have a corresponding stringsOfSize analogue.

This requires a specialised form of Trials<Character> that possesses the magic methods.

sageserpent-open commented 1 year ago

Now I remember why I didn't do this before - there is a lot of delegation from whatever implements CharacterTrials to usual trials implementation. Unless the implementation of TrialsApi is refactored to include some kind of flexible type on the trials it yields (analogous to how SupplyToSyntax is specialised for tuples), this is going to be very messy.

Could use ByteBuddy to set up a delegating proxy of type CharacterTrials that forwards on to the real implementation?

Maybe that second approach would also be useful in the context of #56?

Putting this on to the back burner for now...