stdlib: Implement common assert commands#8515
Conversation
|
After this and #8499 I would like to write a chapter about testing in Nushell in the book. |
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #8515 +/- ##
==========================================
- Coverage 68.51% 68.51% -0.01%
==========================================
Files 624 624
Lines 100562 100562
==========================================
- Hits 68903 68902 -1
- Misses 31659 31660 +1 |
amtoine
left a comment
There was a problem hiding this comment.
i like the fact that you built everything around the assert command 👍
and the assert error is 👌
only minor things i saw and i'll approve this 😉
| # > assert less or equal 1 2 # passes | ||
| # > assert less or equal 1 1 # passes | ||
| # > assert less or equal 1 0 # fails | ||
| export def "assert less or equal" [left: any, right: any, message?: string] { |
There was a problem hiding this comment.
for less or equal, less, greater and greater or equal, maybe you should annotate the left and right arguments with number instead of any.
it looks we can only compare integers, floats, hexadecimal values, ...
these can all be annotated with the number type 👍
There was a problem hiding this comment.
Numbers are not comparable:
× Types mismatched for operation.
╭─[std.nu:112:1]
112 │ export def "assert less or equal" [left: number, right: number, message?: string] {
113 │ assert ($left <= $right) $message --error-label {
· ──┬── ─┬ ───┬──
· │ │ ╰── number
· │ ╰── doesn't support these values.
· ╰── number
114 │ start: (metadata $left).span.start
╰────
help: Change number or number to be the right types and try again.
|
Thank you for the detailed review. I like your comments, I will do them on Monday. |
We NEVER use == to compare floats. Except in Nushell?
|
It is ready to be approved. It seems to fail for an unrelated thing. |
|
I think you'll need to merge main to get rid of this ci error. |
|
I merged main, now it is green. |
|
Thanks |
Implement common assert commands with tests.
Fixes #8419.