Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Concrete interval type tests only indirectly rely on same TypeOperations than tested types #6

Closed
Whathecode opened this issue May 21, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@Whathecode
Copy link
Owner

Whathecode commented May 21, 2022

To remove redundancy in setting up unit tests for each concrete Interval type (e.g. IntInterval implementing Interval<Int, UInt>), BasicTypeIntervalsTest.kt uses an inline function to retrieve the type operations for the type parameters (using getBasicTypeOperationsFor()).

This manually needs to be kept in sync if the operations ever change.

Is there a way to directly retrieve the matching TypeOperations from the concrete types? Maybe through a common factory interface on the companion objects?

@Whathecode Whathecode added the enhancement New feature or request label May 21, 2022
@Whathecode
Copy link
Owner Author

TypeOperations are now statically linked to concrete interval types as an Operations property of the newly introduced IntervalTypeOperations in their companion objects.

This allows reusing these in unit tests to instantiate Interval through it's base class which takes the IntervalTypeOperations parameter.

By doing so, this doesn't test the concrete type interval constructors, but given that these simply forwards the same parameters to the base Interval class there is little risk of mistakes here. Furthermore, these will likely be covered by unit tests once we add API convenience functions such as Byte.intervalTo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant