5 kyu
Function Coercion Errors
121wthit56
Loading description...
Language Features
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
Should add more coercion tests such as:
fn * 2
fn + 2
fn - 2
fn / 2
Pretty much all arithmetic operators, and some comparison operators:
fn == 2
fn < 2
fn >= 2
fn <= 2
No random tests
No sample tests
What is the first test for this kata? Had a few different solutions that all throw errors just fine (in Firefox/Chrome console) when coerced (e.g.
fn > 1
,fn - 3
,+fn
, etc.), but they fail the first test case that saysfn > 1
.There is also a
fn === fn should not throw error
.That was accounted for as well.
fn === fn
andvar a = fn; a === fn
both returntrue
. Only the first test casefn > 1
is showing up red, so it would seem it has to do with the comparison.Oh, in that case you're probably using the wrong method.
There are two methods that are relevant to the kata, and one of them is slightly more obscure.
I don't think that's it either. I checked with both methods: the obvious one (already given in the testing feedback) and the slightly less obvious one. Hmm...funny kata.
Did you figure this out, in the end?
I think this one should be rated as 6 Kyu.
The average was 5kyu, so I ranked it as so.
(I even voted 7kyu before approving it, but then in the end, I rank katas based on the average rank when approving them.)
Approved
No test cases
I'm not sure what you mean?
*coercion.
Thanks.
Nice short one.
Maybe you could provide a testcase with
Test.expectError/expectNoError
since they're not mentioned by default.Not sure what you mean?
When you write your own test cases while solving a kata, there is a comment describing how to use
Test.assertEquals
,Test.expect
, etc. But there is nothing about how to test if something throws an exception or not.Since this kata is all about that, I thought that adding a provided test case that uses
Test.expectError
could teach people how to do that. :-)Oh right. I don't actually write those comments, by the way. The system does it automatically if there aren't any example test cases. I've pasted in the default comment and added a couple of lines about
expectError
andexpectNoError
. Thanks for the feedback.