Skip to content

Commit

Permalink
Test return in reduce closure from nushell#7961 (nushell#7973)
Browse files Browse the repository at this point in the history
# Description

Functionality added by @nabacg in nushell#7961 already

h/t @YuriGeinishO for the example in nushell#7933

Closes nushell#7933


# User-Facing Changes

None

# Tests + Formatting

+1 end to end example
  • Loading branch information
sholderbach authored and Xoffio committed Feb 7, 2023
1 parent 1c9ba6c commit fd080a3
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions crates/nu-command/tests/commands/reduce.rs
Expand Up @@ -46,6 +46,25 @@ fn reduce_rows_example() {
assert_eq!(actual.out, "14.8");
}

#[test]
fn reduce_with_return_in_closure() {
let actual = nu!(
cwd: ".", pipeline(
r#"
[1, 2] | reduce --fold null { |it, state|
if $it == 1 {
return 10
};
return ($it * $state)
}
"#
)
);

assert_eq!(actual.out, "20");
assert!(actual.err.is_empty());
}

#[test]
fn reduce_enumerate_example() {
let actual = nu!(
Expand Down

0 comments on commit fd080a3

Please sign in to comment.