2023-04-07 23:09:55 +02:00
|
|
|
use nu_test_support::nu;
|
2022-07-12 13:03:50 +02:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn error_label_works() {
|
2023-04-07 23:09:55 +02:00
|
|
|
let actual = nu!("error make {msg:foo label:{text:unseen}}");
|
2022-07-12 13:03:50 +02:00
|
|
|
|
2024-06-19 06:37:24 +02:00
|
|
|
assert!(actual
|
|
|
|
.err
|
|
|
|
.contains("label at line 1, columns 1 to 10: unseen"));
|
2022-07-12 13:03:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn no_span_if_unspanned() {
|
2023-04-07 23:09:55 +02:00
|
|
|
let actual = nu!("error make -u {msg:foo label:{text:unseen}}");
|
2022-07-12 13:03:50 +02:00
|
|
|
|
|
|
|
assert!(!actual.err.contains("unseen"));
|
|
|
|
}
|
2023-03-23 20:31:06 +01:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn error_start_bigger_than_end_should_fail() {
|
2023-11-03 16:09:33 +01:00
|
|
|
let actual = nu!("
|
|
|
|
error make {
|
|
|
|
msg: foo
|
|
|
|
label: {
|
|
|
|
text: bar
|
|
|
|
span: {start: 456 end: 123}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
");
|
2023-03-23 20:31:06 +01:00
|
|
|
|
|
|
|
assert!(!actual.err.contains("invalid error format"));
|
|
|
|
assert!(!actual
|
|
|
|
.err
|
|
|
|
.contains("`$.label.start` should be smaller than `$.label.end`"));
|
|
|
|
}
|
2023-11-03 16:09:33 +01:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn check_help_line() {
|
|
|
|
let actual = nu!("error make {msg:foo help: `Custom help line`}");
|
|
|
|
|
|
|
|
assert!(actual.err.contains("Custom help line"));
|
|
|
|
}
|