Add support for while loops (#7101)

This commit is contained in:
JT
2022-11-12 07:21:45 +13:00
committed by GitHub
parent 75556f6c5f
commit 69b089845c
6 changed files with 114 additions and 1 deletions

View File

@ -88,6 +88,7 @@ mod use_;
mod where_;
#[cfg(feature = "which-support")]
mod which;
mod while_;
mod with_env;
mod wrap;
mod zip;

View File

@ -0,0 +1,11 @@
use nu_test_support::nu;
#[test]
fn while_sum() {
let actual = nu!(
cwd: ".",
"mut total = 0; mut x = 0; while $x <= 10 { $total = $total + $x; $x = $x + 1 }; $total"
);
assert_eq!(actual.out, "55");
}