nushell/tests/plugins
Devyn Cairns 8e2917b9ae
Make assignment and const consistent with let/mut (#13385)
# Description

This makes assignment operations and `const` behave the same way `let`
and `mut` do, absorbing the rest of the pipeline.

Changes the lexer to be able to recognize assignment operators as a
separate token, and then makes the lite parser continue to push spans
into the same command regardless of any redirections or pipes if an
assignment operator is encountered. Because the pipeline is no longer
split up by the lite parser at this point, it's trivial to just parse
the right hand side as if it were a subexpression not contained within
parentheses.

# User-Facing Changes
Big breaking change. These are all now possible:

```nushell
const path = 'a' | path join 'b'

mut x = 2
$x = random int
$x = [1 2 3] | math sum

$env.FOO = random chars
```

In the past, these would have led to (an attempt at) bare word string
parsing. So while `$env.FOO = bar` would have previously set the
environment variable `FOO` to the string `"bar"`, it now tries to run
the command named `bar`, hence the major breaking change.

However, this is desirable because it is very consistent - if you see
the `=`, you can just assume it absorbs everything else to the right of
it.

# Tests + Formatting
Added tests for the new behaviour. Adjusted some existing tests that
depended on the right hand side of assignments being parsed as
barewords.

# After Submitting
- [ ] release notes (breaking change!)
2024-07-30 18:55:22 -05:00
..
formats Avoid taking unnecessary ownership of intermediates (#12740) 2024-05-04 00:53:15 +00:00
call_decl.rs Make plugins able to find and call other commands (#13407) 2024-07-19 13:54:21 +08:00
config.rs Use IntoValue and FromValue derive macros in nu_plugin_example for example usage (#13220) 2024-06-26 17:50:14 -05:00
core_inc.rs Avoid taking unnecessary ownership of intermediates (#12740) 2024-05-04 00:53:15 +00:00
custom_values.rs Fix deadlock on PluginCustomValue drop (#12418) 2024-04-05 21:57:00 -05:00
env.rs Make assignment and const consistent with let/mut (#13385) 2024-07-30 18:55:22 -05:00
mod.rs Make plugins able to find and call other commands (#13407) 2024-07-19 13:54:21 +08:00
nu_plugin_nu_example.rs Path migration part 2: nu-test-support (#13329) 2024-07-12 02:43:10 +00:00
register.rs Change PluginCommand API to be more like Command (#12279) 2024-03-27 11:59:57 +01:00
registry_file.rs Path migration part 2: nu-test-support (#13329) 2024-07-12 02:43:10 +00:00
stream.rs Replace ExternalStream with new ByteStream type (#12774) 2024-05-16 07:11:18 -07:00
stress_internals.rs Fix (and test) for a deadlock that can happen while waiting for protocol info (#12633) 2024-04-24 08:44:04 -05:00