Rewrite of the test generator#27
Conversation
|
This PR touches files which potentially affect the outcome of the tests of an exercise. This will cause all students' solutions to affected exercises to be re-tested. If this PR does not affect the result of the test (or, for example, adds an edge case that is not worth rerunning all tests for), please add the following to the merge-commit message which will stops student's tests from re-running. Please copy-paste to avoid typos. For more information, refer to the documentation. If you are unsure whether to add the message or not, please ping |
|
Yeah, you could pull out the slug from either the test file itself or the containing exercise folder. |
test_generator/Assertions.res
Outdated
| * The `digits` argument determines the tolerance (10^-digits). | ||
| * Defaults to 2 decimal places (0.01 tolerance). | ||
| */ | ||
| let floatEqual = (~message=?, ~digits=2, a: float, b: float) => { |
There was a problem hiding this comment.
| let floatEqual = (~message=?, ~digits=2, a: float, b: float) => { | |
| let approximatelyEqual = (~message=?, ~digits=2, a: float, b: float) => { |
Assertion.approximatelyEqual conveys intent better than Assertion.floatEqual.
test_generator/Assertions.res
Outdated
| `Assertions.assertEqual(~message="${message}", ${actual}, ${expected})` | ||
| } | ||
|
|
||
| let dictEqual = (~message=?, a: Dict.t<'a>, b: Dict.t<'a>) => { |
There was a problem hiding this comment.
| let dictEqual = (~message=?, a: Dict.t<'a>, b: Dict.t<'a>) => { | |
| let dictDeepEqual = (~message=?, a: Dict.t<'a>, b: Dict.t<'a>) => { |
This makes it clearer we're checking the keys and values as well.
test_generator/Assertions.res
Outdated
| * The `digits` argument determines the tolerance (10^-digits). | ||
| * Defaults to 2 decimal places (0.01 tolerance). | ||
| */ | ||
| let floatEqual = (~message=?, ~digits=2, a: float, b: float) => { |
There was a problem hiding this comment.
| let floatEqual = (~message=?, ~digits=2, a: float, b: float) => { | |
| let approximatelyEqual = (~message=?, ~digits=2, a: float, b: float) => { |
This conveys intent clearly.
test_generator/Assertions.res
Outdated
| `Assertions.assertEqual(~message="${message}", ${actual}, ${expected})` | ||
| } | ||
|
|
||
| let dictEqual = (~message=?, a: Dict.t<'a>, b: Dict.t<'a>) => { |
There was a problem hiding this comment.
| let dictEqual = (~message=?, a: Dict.t<'a>, b: Dict.t<'a>) => { | |
| let dictDeepEqual = (~message=?, a: Dict.t<'a>, b: Dict.t<'a>) => { |
This clarifies we're comparing the dict keys and values although perhaps we want to make this recursive if it's not too much trouble. That's more than what we need currently of course. However it might be nice to just have a generic recursive assertion for anything with elements.
|
Other than the feedback, is this somewhat in the direction you had previously mentioned? It is not pretty at the moment, and I will invest a lot more time into it if it is to move ahead. |
|
I am going through the exercises one by one. Once I reach the exercises which use comparators other than |
|
Yeah, having the assertion functions as actual ReScript code means we can check them. As strings, we don't have that option. |
There was a problem hiding this comment.
I am a bit stuck here. Having the comparator functions as strings is the only way I can see to inject them into the exercise test files. Copying the old Assertions module into each exercise's test directory isn't feasible.
There was a problem hiding this comment.
this is an abstracted version of the comparator function that we can use.
Draft
Before I go any further, I would like some feedback on how we might handle test templates moving forward.
test_templatesdirectory, where test templates are now written in pure ReScript_testpart.)I have re-implemented a few of the exercises using this test generator for your review.