-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
test(math.vector): add tests for GetAngleBetweenVectorsOnPlane function #12974
test(math.vector): add tests for GetAngleBetweenVectorsOnPlane function #12974
Conversation
Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s). |
Snapshot stored with reference name: Test environment: To test a playground add it to the URL, for example: https://babylonsnapshots.z22.web.core.windows.net/refs/pull/12974/merge/index.html#WGZLGJ#4600 Links to test babylon tools with this snapshot: https://playground.babylonjs.com/?snapshot=refs/pull/12974/merge To test the snapshot in the playground with a playground ID add it after the snapshot query string: https://playground.babylonjs.com/?snapshot=refs/pull/12974/merge#BCU1XR#0 |
Thanks for that! I wonder - how were these numbers generated? And why do we need 1000 tests and not a few fixed (and tested) ones, including edge cases? |
Yes, I want to discourse! =) As edge cases I take Number.MIN_INTEGER_VALUE and max. Also I take zero and value close to zero 0.00000001 (negative and positive).
The function take 3 input Vector3 (3 input by 3 value), so to calculate all possible test cases we should Is all of them required? It is hard question. But I got some interesting insight. |
I will go over it in depth in an hour or two :-) How were they generated? using the same function? |
No, just simple for loop. I dont save it but it was looking like: for (let i = 0; i < 1000; i++) {
testCases.push({
v0: { x: getRandomPossibleValue(), /* y: ... */ },
// same for
// v1:
// normal
});
} after run it I fill the result and save it as fixed test cases as array in this PR. |
I mean the results :-) You are testing the function against the results it has generated, right? So this test is only testing if the function has changed? Or have you generated the results using some other method? |
Right, I got current results by current state of the function with trust that it work correct.
Yep. What do you think, which is the best way to write unit tests in such case? |
Nope, I just wanted to be sure what is being tested :-) |
I just thought that this way to testing is good for long living high-order functions and I want to discourse it with you, what is the best way? Leave public functions without any tests is not good definitely, but how to test them right? |
And what do you think? Will some similar PRs be helpful if I make some of them? For me, it is an interesting way to get to know framework. |
Of course. I would rather not have 1000 test cases (10-20 would be great :-)), but we are always happy for these kinds of PRs! |
I understand you, but this situation looks like a potential problem when we talking about limited test cases:
|
…on (#12974) Former-commit-id: ba093fcbe5c697137fd55d4ef50f7eabc43cd255
I generated 1000 variants of usage the GetAngleBetweenVectorsOnPlane function base on these values:
So I got time comutation statistics that added to jsdoc.
What do you think about unit tests like this? Or probably we should set just several examples without edge values (like max_safe_integer)?