nu-command 0.114.1

Nushell's built-in commands
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use nu_test_support::nu;

// Companion to the `for` non-block-body regression test
// (https://github.com/nushell/nushell/issues/13746): passing a non-block
// (e.g. a bare variable) as the `if` body must surface a clean
// `nu::compile::invalid_keyword_call` error from the IR compiler and never
// panic, per the AGENTS.md "No panicking on user input" guideline.
#[test]
fn if_with_non_block_body_errors_without_panic() {
    for src in ["if true $nu", "if true $nu else { 1 }"] {
        let actual = nu!(src);
        assert!(actual.err.contains("invalid_keyword_call"));
        assert!(!actual.err.to_lowercase().contains("panic"));
    }
}