junit-quickcheck icon indicating copy to clipboard operation
junit-quickcheck copied to clipboard

Make Generator an interface

Open vlsi opened this issue 5 years ago • 2 comments

Currently, Generator is a class, and it makes it complicated to implement generators.

For instance, I already have a generator, however, it extends its own class for simplified API.

Base class: https://github.com/apache/calcite/blob/763ec429c951acd5fa251c5d4a2b7780fbf648d4/core/src/test/java/org/apache/calcite/rex/RexProgramBuilderBase.java#L44

Uses in the generator: https://github.com/apache/calcite/blob/763ec429c951acd5fa251c5d4a2b7780fbf648d4/core/src/test/java/org/apache/calcite/test/fuzzer/RexFuzzer.java#L184

It does not hurt much, however, at this point it looks like all the Generator / Shrinker behavior can be implemented with interface default methods.

vlsi avatar Jan 19 '20 07:01 vlsi

@vlsi Thanks for this. I'm open to having Generator become an interface. My main concern is avoiding breaking existing subclasses of Generator, as you might expect. I'll noodle on this a bit.

pholser avatar Jan 19 '20 18:01 pholser

My main concern is avoiding breaking existing subclasses of

I see.

There are two options at least:

  • Just do it :) junit-quickcheck is 0.x, so slight glitches in the backward compatibility are expected by the consumers
  • Add super interface for those who want to implement a generator without having to extend a base class (and use it internally instead of the current Generator)

vlsi avatar Jan 19 '20 18:01 vlsi