-
-
Notifications
You must be signed in to change notification settings - Fork 161
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 dnd-character
exercise
#751
Conversation
4467bb9
to
fbdc253
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's very difficult to review this. It includes more tests than the canonical data, the descriptions don't seem to match the canonical data, and there are even tests like (>= (count (set (repeatedly 100 #(dnd-character/ability)))) 5)
, which I can't locate in the canonical data.
Extensive deviations from the canonical data make it very challenging to perform manual comparisons when something needs to be inspected.
Were there specific reasons for these deviations?
Yes, because this an exercise which canonical data in large part describe "properties," not concrete test values. This is due to the fact that we're dealing with randomness, which doesn't fit well into the regular canonical data format.
I understand, but in this case I feel extra tests are warranted. {
"uuid": "4f28f19c-2e47-4453-a46a-c0d365259c14",
"description": "random ability is within range",
"scenarios": ["random"],
"property": "ability",
"input": {},
"expected": "score >= 3 && score <= 18"
}, In essence, this is specifying two things:
This is why the additional test is added. We could combine them into a single test, but I feel that a separate test makes more sense. Basically what I want to test is that the function does not keep on returning the same values, but that it is doing something random. A similar argument applies to the tests for the {
"uuid": "385d7e72-864f-4e88-8279-81a7d75b04ad",
"description": "random character is valid",
"scenarios": ["random"],
"property": "character",
"input": {},
"expected": {
"strength": "strength >= 3 && strength <= 18",
"dexterity": "dexterity >= 3 && dexterity <= 18",
"constitution": "constitution >= 3 && constitution <= 18",
"intelligence": "intelligence >= 3 && intelligence <= 18",
"wisdom": "wisdom >= 3 && wisdom <= 18",
"charisma": "charisma >= 3 && charisma <= 18",
"hitpoints": "hitpoints == 10 + modifier(constitution)"
}
} As you can see, this test case actually has at least 7 different tests, and with the added test for random generation, we get 8 tests encoded by a single test case property. |
@tasxatzial What do you think about naming the functions |
My preference is to use verbs for function names, but I understand this can sometimes result in verbose names. As such, I'm not too particular about naming. I don't believe the official documentation strictly follows this guideline either. In my view, reasons to switch from
|
fbdc253
to
fd2443f
Compare
Okay. I've updated the PR |
Couple extra suggestions before i do a proper review:
|
fd2443f
to
dbad29c
Compare
Is this something that you would like to see changed for all exercises? |
I've updated |
dbad29c
to
115627b
Compare
@tasxatzial I've created a PR to update the separator: #779 Let's get that merged first and then I'll update this PR |
Ok, there are still some updates pending on this one:
One case seems to have been excluded. It would be helpful to mention why. I'm considering creating an issue that lists all the factors considered for each exercise. This will make it easier to track important details for future reference. |
With the recent updates, I'll wait until all open PRs are updated. |
39d46ec
to
9252c99
Compare
Okay updated. I've tried to include the "calculated only once" tests. Let me know what you think. The idea is that the value is calculated each time the key is accessed, but is that even possible in Clojure? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, i've finally managed to go over this. It's not as complicated as i though it would be. Hopefully i haven't missed anything.
The modifier tests look fine.
The ability tests are broken into two, as you said. The second test looks fine. But the first one is generating the ability only once. Is this sufficient for checking that values are within range?
The 'random character test is valid' tests are split into multiple. I'm guessing you went with the property-tested suggestion from the specs? Same as the ability tests, there's one test for each ability. Is this sufficient for checking that values are within range?
Regarding the 'each ability is only calculated once' tests. What's the purpose of those tests in the specs? I'm not even sure how to interpret them.
I guess it's better to also do this for a number of times. Good call.
Correct. If you'd like
We should also do this check repeatedly, certainly!
The original idea of the canonical data is that there will be languages where the character's abilities are methods. The test case is to check that that method isn't just returning a random value each time it is called. I guess this doesn't make sense in Clojure, does it? |
We can make the character's abilities function calls if we want, but i believe that something like |
Co-authored-by: Anastasios Chatzialexiou <[email protected]>
Co-authored-by: Anastasios Chatzialexiou <[email protected]>
Co-authored-by: Anastasios Chatzialexiou <[email protected]>
Co-authored-by: Anastasios Chatzialexiou <[email protected]>
Co-authored-by: Anastasios Chatzialexiou <[email protected]>
Co-authored-by: Anastasios Chatzialexiou <[email protected]>
Co-authored-by: Anastasios Chatzialexiou <[email protected]>
Co-authored-by: Anastasios Chatzialexiou <[email protected]>
Co-authored-by: Anastasios Chatzialexiou <[email protected]>
11a0ad2
to
dd7e98e
Compare
Ready for a new check |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
No description provided.