prevent panic with format command (#7522)

Related: #7211.

Prevents numeric underflow in span.

Co-authored-by: sholderbach <sholderbach@users.noreply.github.com>
This commit is contained in:
pwygab
2022-12-19 20:10:02 +08:00
committed by GitHub
parent a21af0ade4
commit dae1b9a996
2 changed files with 31 additions and 3 deletions

View File

@ -42,6 +42,19 @@ fn can_use_variables() {
assert_eq!(actual.out, "nu is a new type of shell");
}
#[test]
fn error_unmatched_brace() {
let actual = nu!(
cwd: "tests/fixtures/formats", pipeline(
r#"
open cargo_sample.toml
| format "{$it.package.name"
"#
));
assert!(actual.err.contains("unmatched curly brace"));
}
#[test]
fn format_filesize_works() {
Playground::setup("format_filesize_test_1", |dirs, sandbox| {