1
0
mirror of https://github.com/nushell/nushell.git synced 2025-03-26 07:19:55 +01:00
nushell/crates/nu-std/tests
NotTheDr01ds a2873336bb
Fix do signature ()
Recommend holding until after  is fully digested and *possibly*
until 0.96.

# Description

Fixes one of the issues described in  

The `do` signature included a `SyntaxShape:Any` as one of the possible
first-positional types. This is incorrect. `do` only takes a closure as
a positional. This had the result of:

1. Moving what should have been a parser error to evaluation-time

   ## Before

   ```nu
   > do 1
   Error: nu:🐚:cant_convert

     × Can't convert to Closure.
      ╭─[entry #26:1:4]
    1 │ do 1
      ·    ┬
      ·    ╰── can't convert int to Closure
      ╰────
   ```

   ## After

   ```nu
   > do 1
   Error: nu::parser::parse_mismatch

     × Parse mismatch during operation.
      ╭─[entry #5:1:4]
    1 │ do 1
      ·    ┬
      ·    ╰── expected block, closure or record
      ╰────
   ```  

2. Masking a bad test in `std assert`

This is a bit convoluted, but `std assert` tests included testing
`assert error` to make sure it:

* Asserts on bad code
* Doesn't assert on good code

The good-code test was broken, and was essentially bad-code (really
bad-code) that wasn't getting caught due to the bad signature.

Fixing this resulted in *parse time* failures on every call to
`test_asserts` (not something that particular test was designed to
handle.

This PR also fixes the test case to properly evaluate `std assert error`
against a good code path.

# User-Facing Changes

* Error-type returned (possible breaking change?)

# Tests + Formatting

- 🟢 `toolkit fmt`
- 🟢 `toolkit clippy`
- 🟢 `toolkit test`
- 🟢 `toolkit test stdlib`

# After Submitting

N/A
2024-06-29 16:17:06 -05:00
..
logger_tests fix std log () 2024-04-10 17:30:58 -04:00
test_asserts.nu Fix do signature () 2024-06-29 16:17:06 -05:00
test_dirs.nu dirs goto: update current ring slot before leaving it. () 2023-10-13 06:46:51 -05:00
test_dt.nu std dt datetime-diff: fix uninitialized field ref when borrowing () 2023-09-24 10:53:56 +02:00
test_formats.nu to json -r not removing whitespaces fix () 2024-03-20 22:14:31 +01:00
test_help.nu fix std help () 2024-05-23 08:51:02 -05:00
test_iter.nu Implement annotations support in test runner () 2023-07-02 10:41:33 +02:00
test_setup_teardown.nu Implement annotations support in test runner () 2023-07-02 10:41:33 +02:00
test_std.nu Surprising symlink resolution for std path add () 2024-06-28 18:11:48 -05:00
test_xml.nu Implement annotations support in test runner () 2023-07-02 10:41:33 +02:00