mirror of
https://github.com/nushell/nushell.git
synced 2024-11-29 03:44:19 +01:00
e8764de3c6
# Description Fixes: #11451 # User-Facing Changes ### Before ```nushell ❯ [1 2 3] | each {|e| break; print $e } ╭────────────╮ │ empty list │ ╰────────────╯ ``` ### After ``` ❯ [1 2 3] | each {|e| break; print $e } Error: nu:🐚:eval_block_with_input × Eval block failed with pipeline input ╭─[entry #9:1:2] 1 │ [1 2 3] | each {|e| break; print $e } · ┬ · ╰── source value ╰──── Error: × Break used outside of loop ╭─[entry #9:1:21] 1 │ [1 2 3] | each {|e| break; print $e } · ──┬── · ╰── used outside of loop ╰──── ``` # Tests + Formatting Removes some tests.
18 lines
324 B
Rust
18 lines
324 B
Rust
use nu_test_support::nu;
|
|
|
|
#[test]
|
|
fn break_for_loop() {
|
|
let actual = nu!("
|
|
for i in 1..10 { if $i == 2 { break }; print $i }
|
|
");
|
|
|
|
assert_eq!(actual.out, "1");
|
|
}
|
|
|
|
#[test]
|
|
fn break_while_loop() {
|
|
let actual = nu!(r#" while true { break }; print "hello" "#);
|
|
|
|
assert_eq!(actual.out, "hello");
|
|
}
|