mirror of
https://github.com/nushell/nushell.git
synced 2024-11-24 17:34:00 +01:00
Tests: add a test to make sure that function can't use mutable variable (#14314)
@sholderbach suggested that we need to have a test for a function can't use mutable variable. https://github.com/nushell/nushell/pull/14311#issuecomment-2470035194 So this pr is going to add a case for it. --------- Co-authored-by: Stefan Holderbach <sholderbach@users.noreply.github.com>
This commit is contained in:
parent
e6f55da080
commit
a3c145432e
@ -141,3 +141,10 @@ fn mut_raw_string() {
|
|||||||
let actual = nu!(r#"mut x = r#'abc'#; $x"#);
|
let actual = nu!(r#"mut x = r#'abc'#; $x"#);
|
||||||
assert_eq!(actual.out, "abc");
|
assert_eq!(actual.out, "abc");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn def_should_not_mutate_mut() {
|
||||||
|
let actual = nu!("mut a = 3; def foo [] { $a = 4}");
|
||||||
|
assert!(actual.err.contains("capture of mutable variable"));
|
||||||
|
assert!(!actual.status.success())
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user