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.
??? The Java equivalent is
null
, like in C# and Javascript. The Void type in Java has no public constructor, so you can't callnew Void()
and you can't return an instance of Void. It's just there to represent thevoid
keyword as something you can interact with.This comment is hidden because it contains spoiler information about the solution
Other way around: All the assertions were the same. The it descriptions were correct.
Putting everything in the same function fixes that, they're all cozying up in the same
it
but whatever I guess. That works.Right, all tests are different but "it" description is wrong.
Modified the random tests for "it" and used copies to avoid mutation effects.
If you have time maybe you could have a look and re-raise an issue if needed.
Additionally, as mentioned above, input can be mutated to affect what the reference receives. (Which is likely to happen considering that array.sort mutates)
one could also argue that fixed tests shouldn't share an
it
and should show what the input is. depends on whether one expects the user to printf debug or not.@g964 no, you're wrong. the
it
description is not what is being asserted.@ChrisMassie: I can see your solution and I tried it; it has always passed, many times, but maybe I didn't see and try your first version... I suppose the input was mutated somewhere. Nevertheless I will modify this part
assert.strictEqual(comp(a1, a2), reference(a1, a2));
.@natan:
You are wrong the inputs are never the same. For example here are the first two random tests of a try:
Nah it expects based on what it sends you, not based on the header, which suggests that you truly did fail that test.
the header runs immediately, which is why they print the correct test cases. the callback runs 100 times after the loop, all with the same
a1
anda2
. both the reference and your solution are receiving the same input, so the expectation will be correct for that one case which is repeated 100 times. maybe you mutate input, which would make the reference get different input (that's also something that needs to be fixed, the reference should run first, or use a copy, or mutation should be detected)In the execution I copy+pasted the header + log from for the wrong result, it was expecting false, which would have been correct for the arguments it was supposed to be passing according to the header. My function returned true, which was correct for the actual arguments it was given. Even if you don't get it to fail, you can see the arguments it's supposed to pass and the arguments it actually passes are different if you print the arguments.
Yeah, the tests don't use closures correctly, capturing variables instead of values and therefore run the last testcase 100 times (the other 99 don't get tested)
This could be fixed by wrapping it in a function like so:
That doesn't explain how you fail the assertion though, or why it expects false. The reference solution gives true for the input you printed (as it should). Maybe your solution is wrong, but I can't tell without being able to reproduce and make my own observations.
Doing it in Typescript. The first random test consistently (EDIT: semi-consistently) fails and, going by
console.log
calls, it looks like it's because it's asserting the result of one set of inputs while actually calling the function with a different set.Where my solution begins with:
The first random test fails with
expected true to equal false
, where the first random test's header reads: (wrapped for readability)but the console log reads:
Every other test passes with my current solution.
EDIT: Looking at the logs of the rest of the random tests, regardless of what the test header says they're testing, they all (except the first) have the log output:
The Swift tests are still broken.
The sample tests fail by themselves independent of the solution code: https://i.imgur.com/qwh8jTm.png
The "attempt" random tests expect the wrong results for "8.2M ohms" ( https://i.imgur.com/21Xarxu.png ) and "4.1M ohms". ( https://i.imgur.com/ppBHn61.png )
I did not mean to submit that ~_~ I was trying to get the "attempt" random tests to test with "8.2M ohms", which seems to test for the wrong answer. (At least in the Swift version)
Ah. I completed it for Swift. The tests given for swift require a different format from the tests for every other language.
@ChrisMassie: which language? You are right: it can depends on the language. You see that in "Sample Tests".
Loading more items...