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

Add property-based testing #59

Closed
nbraud opened this issue Oct 11, 2018 · 4 comments
Closed

Add property-based testing #59

nbraud opened this issue Oct 11, 2018 · 4 comments

Comments

@nbraud
Copy link
Collaborator

nbraud commented Oct 11, 2018

I think it would make sense, in many cases, to run tests not against hardcoded inputs (and expected outputs), but against random inputs (and properties/equations that should hold).
For instance, x.angle(x.rotate(alpha)) ≃ alpha for any vector x and angle alpha.

Given that ppb-vector is a math library, and written in an effects-free style, it seems to be a great fit for property-based testing, and I can recommend the Hypothesis property-based testing library.

It would probably make sense to first add some automation to track line- or path-coverage of the testsuite, ideally ran automatically in CI, but this isn't a strong blocker either.

@AstraLuma
Copy link
Member

It's hard to do useful things with coverage without roping in another service.

Also, #58.

@nbraud
Copy link
Collaborator Author

nbraud commented Oct 11, 2018

@astronouth7303 I suggested coverage tracking because this would allow removing unit tests that were superseded by property-based tests with confidence, but that doesn't need to be done in CI if you don't mind checking by hand when reviewing a PR that removes a unit test.

@pathunstrom
Copy link
Collaborator

As a long term thing, I just check coverage occasionally on my own machine but don't make it a hard block on contribution.

Most of that is because I want ppb to be a good entry point for getting into open source, and adding extra tools is. . . not my idea of making that entry point easy.

That said, I don't think that has to stay true across all the tools we build and ppb vector, while being build to handle 2d games only (and therefore does some things that math folks might hit me for) it's one of the more advanced pieces of the system.

@nbraud
Copy link
Collaborator Author

nbraud commented Dec 10, 2018

This can be closed, as the latest round of PRs should have brought pretty good coverage of the API with property-based tests.

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

No branches or pull requests

3 participants