Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
This comment is hidden because it contains spoiler information about the solution
me too. Did you ever figure it our?
Test.assertDeepEquals
Well, two ideas came to my mind.
First. You just override
Array.prototype.reduce
andArray.prototype.concat
to your function that will throw an error,you can't use this method
or something simillar.Second, you still override it, but with an inner counter of invokes. You would assing these functions to a variables and on the prototype you would write your own function simillar to this.
The test would check the counter if it has changed. In my mind this works, but you would have to check that for yourself ;).
Please consider me a n00b specially in unit test but I really want this kata to get better.
Can you tell me how to make a test whether or not
reduce
was used?Also I don't know if its possible to test if the solution has recursion. Thanks!
You may wish to describe what 'flattening' an array means for those not familiar with the term, and provide a few examples. This does appear to be similar to another kata, btw.
If the arrays contain various data types and not just Numbers, then my "cheating" solution will fail.
You're not checking that
reduce
andconcat
are not used.I am new to unit testing, how can I use assert.deepEqual?
The remainder should always have the same sign as the number you're dividing.
a
divided byb
equalsc
with a remainder ofd
(a = b * c + d
).Try running these tests:
My code is passing all the test, but when I submit it, it says
Should handle negative numbers - Expected: 40, instead got: -20
Any tip in handling negative numbers?