std.nu: Rewrite assert method#8405
Conversation
|
@amtoine I think with this change even using With assertWith assert eqI'd consider the value added by At first step I did not want to make much change, just send the proposed |
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #8405 +/- ##
==========================================
+ Coverage 68.11% 68.51% +0.40%
==========================================
Files 620 620
Lines 99709 99723 +14
==========================================
+ Hits 67914 68329 +415
+ Misses 31795 31394 -401 |
|
@presidento i'll have a look after lunch for sure 😉 |
There was a problem hiding this comment.
loving it 🚀
in order to have these beautiful error messages on assert eq and assert ne as well, could you modify _assert instead of assert? 😋
and maybe the _assert tool has to be dropped and the error messages reimplemented in assert, assert eq and assert ne separately to accomodate the number of arguments and the way of the boolean test 🤔
i've written the _assert in the firt place but it can go away i think, not a big deal if that allows such great error messages! 😏
|
Here is the next step. The I implemented it for I am confused with |
3823fd6 to
7208046
Compare
Make error messages more descriptive. Allow to add message to assertions.
|
@presidento and that's not the most convenient for reviewers to checkout your branch and test what has been done, i think 😋 |
|
i think the names have been chosen to reflect what is done with and about |
|
In my organization we are allowed to push only perfect commits to master, so we rebase&change commits as long as they are not in the preferred state. If it has no value for this repository, I can leave existing commits as they are and do every change in follow-up commits. |
the |
amtoine
left a comment
There was a problem hiding this comment.
one extra thing apart from the type check in assert ne, the tests do not pass anymore, so there might be something to investigate there to fix them 😌
nu crates/nu-utils/standard_library/tests.nunow fails
To be consistent with > 1 != "foo" true and > (1 + 2) != 3) true
|
not sure what to do with these failing tests 🤔 i think
|
|
[edit: just reread your question above @amtoine, you're right. So read my original response as support for removing the type check from the asserts...] It appears that Nushell will let you compare items of different types without complaining about type mismatch. 〉1 == 1.0
true
〉true == 1
falseThe |
|
Due to having 2 devs busy in the same 2 files on the same day, this PR drops out the automatic loading of This is developer-hostile design, we shouldn't have such race conditions for unrelated sub-modules. Ideally, developer of a sub-module (like |
|
Who is the leader here? As I started to receive contradicting requests, I
need to know whom to follow.
1) May I rebase this branch? If yes, can I squash it into one commit?
2) Can I keep `assert $a != $b` consistent with `assert ne $a $b`?
|
|
i think we need some help here to decide what to do with TL;DR: should
|
|
i can say for sure @bobhy and i are not members of the core team 👍 the standard library is a very recent project with a lot of design being defined right now 😮 |
|
I'd defer to @kubouch's opinion. |
|
(I reverted the change of behaviour and created additional issues for the mentioned topics. Now this PR is just about the detailed error messages and be able to add custom message to assert methods.) |
|
By reading the posts here, it seems like it should work before except |
|
There should be no behaviour change at all. Let me explain it. (Also, there are unit tests for these commands.) assertIt is the same. Previously assert eqPreviously assert nePreviously Here the order changed to have a better error message, but still
Custom message for assertionsYes, it is changed, now you can add custom messages, but it is optional, so no behaviour change for existing codes: |
👍
👍
this is where i disagree 😋 previously we had but now we have which does not look the same to me 😮
i hope i'm not becoming blind to what is written here, i've seen so much |
|
i'm sorry being that picky here... before we had the |
|
At the end of the day it is your code. If you don't like the style, feel free to "be inspired" with this PR, reject this one and resend a new one with the style you want. I will 👍 it. From functional point of view I am sure they are identical. |
nope it is absolutely not, i know "my" asserts had a lot of flaws that need to be addressed 👍
i did not check all the workings of
what i'm saying is that the whole logic inversion introduced here is confusing to me, merely to add better message that just require passing the in the end, "changing the style" might have been better kept in a separate and clearer PR, leaving the "better messages" (and they truely are, don't get me wrong 💪) for this one. @fdncred |
|
For having better error messages, the error-making part must be extracted, since it is the (only) common part. It has an inverse behaviour compared to |
|
Other than not having no-op blocks, this code seems pretty good to me. |
|
Done |
|
Let's land this then :) |
|
🥳 noishe |
# Description Was original asked here: #8405 (comment) Make it easier to extend standard library with submodules. (For a new submodule called `xx.nu` the tests can be written in `test_xx.nu`). Test discovery is implemented. # User-Facing Changes There are no user-facing changes. # Tests + Formatting Tests are updated. There is no `nufmt` now. --------- Co-authored-by: Mate Farkas <Mate.Farkas@oneidentity.com>
It is a common pattern to add message to assert.
Also the error message was not so helpful. (See the difference in the documentation)