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.
Are you talking about the use of
self
in the properties/getters/fields section of the spec? I was usingself
for consistency with the spec in all the other languages which use self/this.As far as seeing
self
in other languages that don't have it, theself.___
listings are all in language-conditional blocks, so they will only show in rust. (In fact, each of those listings has a conditional block for each language the kata supports, with each listing using self/this.)1.Unfortunately not, there's some magic that
assert_eq!
does that is difficult to replicate.assert_eq!
is also the standard for writing tests anyway, so adding an error message should be enough for your average rust programmer.4.I guess it would be possible, but very ugly and not at all idiomatic. It is not uncommon for tests in the wild to always output a stdout trace, because the compiler and package manager is configured to conditionally block stdout depending on the results of tests and how many are being run. (I think the rust way to solve this problem is set TRACE to true, and let the compiler do the rest.)
Note: I renamed
nice_assert_eq
to bechem_assert
because I keep overloading it with common functionality (checking lists of test strs, checking for errs, etc.)I took a (minimally-invasive) swing at it. Let me know if there's anything else to be done.
That worked - thanks!
Thanks, it was a good challenge! I use your translations all the time, so the shout out means a lot.
That's a good tip about shifting the
mod preloaded
into the test suite - change published!Sure! How do I get on to the discord? The links don't appear to work... :(
I have made the macro
nice_assert_eq!
that aims to make the debug output and the test cases more legible. Let me know what you think.As far as missing messages for (what used to be called) property_method_and_locking, could you be more specific? I'm not seeing what's missing, sorry.
Index out of bounds errors should no longer occur in the test suite regardless of the length of
m.atoms()
. In places where non-zero length is expected, there are custom assert statements inserted.I took all your bullet-point suggestions, except for two:
EmptyMolecule_Err_if_no_branches_after_unlock
raises a warning in the compiler. I rephrased it toempty_molecule_err_if_no_branches_after_unlock
to avoid that issue.You will see many comments inside
remove_empty_branches_after_unlocking
. The python test implementation actually violates the spec inside the commented-out code. The Final Notes section in the description say that "Methods will always receive valid arguments, e.g. carbon or branch numbers..." Because that line provides an invalid(nc, nb)
, it triggers undefined behavior. I had removed the test because of this, but I put back everything (but the bad line) so you can take a look.A suggestion about how to fix this: we could design it so that mutating (2, 2) would cause an InvalidBond exception/err instead of going out of bounds only if the branches were not updated properly. For example:
TRACE
constant now, set tofalse
.m.bond(..).expect("something bad happened")
, only ifbond
returns andErr("error data")
, then the program will crash (or the test will fail) with stderr:In other words, the calls
m.bond(&[(5,1,3,2)]).expect("[...]")
works just like the python below from your tests, printing any error that occurred and the message with it:Sorry, I'm new to the discourse interface - I replied in a comment above!
#[derive(Hash)]
). Because it was not necessary for the rust implementation of the tests (I never used a map of any kind) and it is very unusual to implement by hand (like JS which does not have a hash requirement, but unlike Python/Java which do), I decided to drop the requirement. I just forgot to remove the comment - sorry!mol!
is a fairly complex macro, but something likemol!("name", fn1(arg1), fn2(arg2, arg3), fn3())
will eventually expand toThe
expect
statements are required for rust error handling, and they do the same thing as?
except that they give the provided error message as well as the default one.As you can see, most of
mol!
's job is to inform the user which function call failed, if any.Essentially, it does no magic, follows the spec, and hopefully makes the debugging experience easier.
4. In rust, all tests are run in a non-deterministic order (it's random). The fact that biotin came up first is just luck, in fact, it's technically third in the order the tests are written. The only way around this is prevented by codewars, because we can't access the compiler config file (
Cargo.toml
). I do like the idea of it as a grand finale though... sorry!5. Random tests are implemented. Like how your python random tests depends on your python solution, my rust tests depend on my solution to the problem. I have made sure not to leak any of the solution in the sample tests though!
This comment is hidden because it contains spoiler information about the solution
Thansk for the feedback. This is now fixed!
When I was using this to play twister, it was certainly helpful!
If there's a more concrete reason to remove it, feel free to reply.
Ok thanks!
Done!
This should be fixed!
Loading more items...