Entomy / LibLangly

The combined Langly runtime
https://entomy.github.io/LibLangly/
33 stars 7 forks source link

Trait Testing #295

Closed Entomy closed 2 years ago

Entomy commented 3 years ago

The Traits API does a lot to codify a consistent public API across disparate types without imposing the problems of a class hierarchy. However, this introduces a bit of a problem: how does one ensure compliant behavior with the trait?

To address this, I'm proposing a trait testing contract API. The idea behind this is codifying a number of extensions to the Philosoft.Testing API. One part of this is a number of interfaces that test classes shall implement, providing test methods will well defined names and parameters; this serves as the foundation for codifying the other parts. Next is a consistent set of test data that the tests can accept.

What I'm a bit unsure about still is if the internals of the test can themselves be codified, or if downstream always needs to provide these consistently. The issue is that internal behavior is not 100% consistent, but rather just conceptually so. Consider the simple case of adding an element to a collection. Adding to a linked list will link a new node. Adding to a dynamic array might resize the internal buffer. Adding to a bounded array might overflow and throw an exception. It's this last one that introduces the problem. Conceptually they are all fine and behave the same way up until the overflow. How would a codified test address this? This will have to be solved.

Entomy commented 2 years ago

This is no longer necessary as I'm no longer using this approach.