Ad
  • Custom User Avatar

    Hi, could you take a look at the issue Awesome opened about the rust translation, please?

  • Custom User Avatar

    Looks like it's good to go? Did I miss anything in the wall of text below?

  • Custom User Avatar
  • Custom User Avatar

    Are you talking about the use of self in the properties/getters/fields section of the spec? I was using self 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, the self.___ 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.)

  • Custom User Avatar

    ok, just forget about the global TRACE thing, keep it at True in the tests.

    I'm not competent anymore for the other stuff, so just poke at me when the translation is ready for approval.

    NOTE: for an unknown reason, I don't receive any notification anymore when a message is posted here, so when done or if some context is needed plz poke at me on discord.

    Cheers

  • Custom User Avatar

    Note: you can use assert! with a custom comparison as first argument (e.g. compare actual to expected), and a fully custom assertion message as second argument. This doesn't output the boilerplate "left == right" stuff that you get with assert_eq!, only your own assertion message.

  • Custom User Avatar

    I think replacing self with atom would be more sensible (not all languages have the notion of self being the instance, some have this, others might not have that concept at all?). It should be clear that atom would then be referring to an instance of the Atom type, since that is mentioned in the text directly above.

  • Custom User Avatar

    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 be chem_assert because I keep overloading it with common functionality (checking lists of test strs, checking for errs, etc.)

  • Custom User Avatar

    ok, code used in python:

            m = Molecule().brancher(1,5).bounder((2,2,5,2), (4,2,1,1)).mutate((1,1,'H'))
            m.brancher(3).bounder((2,3, 1,3), (2,3, 3,3))
            exp = ['Atom(H.1: C5)', 'Atom(C.2: C3)', 'Atom(C.3: C2,C4,C6)', 'Atom(C.4: C3,C5)', 'Atom(C.5: C4,C6,H)', 'Atom(C.6: C3,C5)', 'Atom(C.7: C8,C8)', 'Atom(C.8: C7,C7,C9,C9)', 'Atom(C.9: C8,C8)'] 
            test.assert_equals(extractNoneHToStr(m, True), exp, "Check correctness so far, before the tricky part")
            
            m.closer().unlock()
            test.expect_error( "Should remove any empty branch: m.add([2,2,'P']) shouldn't work, now, since the targeted carbon (previously thrid on the branch) cannot accept new bounds.",
                               lambda: m.add((2,2,"P")) )
            
            m.add((2,1,"P"))
            exp = ['Atom(C.1: C2)', 'Atom(C.2: C1,C3,C5,P9)', 'Atom(C.3: C2,C4)', 'Atom(C.4: C3,C5)', 'Atom(C.5: C2,C4)', 'Atom(C.6: C7,C7)', 'Atom(C.7: C6,C6,C8,C8)', 'Atom(C.8: C7,C7)', 'Atom(P.9: C2)']
            test.assert_equals(extractNoneHToStr(m), exp, "Should have removed correctly the first empty branch and should have used what was previously the second branch as the currently first one")
         
    
  • Custom User Avatar

    ok, sounds good to me.

    .1 => I still see some left/right, as in:

    tests::atom_spec::atom_display
    assertion failed: `(left == right)`
      left: `"Atom(C.1)"`,
     right: `"Atom(C.1x"`: "Atom(C.1)" should be "Atom(C.1x"
    

    Would that be possible to have actual/expected (or the opposite, I didn't check which one it is) instead of left/right everywhere?

    .3 => yeah, good idea. I'll update the other languages.

    .4 => about the TRACE thing, the idea is that the user can change the setting through their solution, to help debugging. I didn't see it defined in there or in preloaded => ?

    Everything else seems fine to me.

    Cheers!

  • Custom User Avatar

    I took a (minimally-invasive) swing at it. Let me know if there's anything else to be done.

  • Custom User Avatar
  • Custom User Avatar
  • Custom User Avatar

    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!

  • Custom User Avatar

    Sure! How do I get on to the discord? The links don't appear to work... :(

  • Loading more items...