mirror of
https://github.com/nushell/nushell
synced 2024-12-27 05:23:11 +00:00
Fix tests
This commit is contained in:
parent
15bc5bc5ed
commit
bd3cdbb029
10 changed files with 29 additions and 23 deletions
|
@ -240,7 +240,9 @@ fn test_computable_style_closure_errors() {
|
|||
];
|
||||
let actual_repl = nu!(nu_repl_code(&inp));
|
||||
// Check that the error was printed
|
||||
assert!(actual_repl.err.contains("type mismatch for operator"));
|
||||
assert!(actual_repl
|
||||
.err
|
||||
.contains("nu::shell::operator_incompatible_types"));
|
||||
// Check that the value was printed
|
||||
assert!(actual_repl.out.contains("bell"));
|
||||
}
|
||||
|
|
|
@ -62,7 +62,9 @@ fn concat_assign_type_mismatch() {
|
|||
$a ++= 'str'
|
||||
"#);
|
||||
|
||||
assert!(actual.err.contains("nu::parser::unsupported_operation"));
|
||||
assert!(actual
|
||||
.err
|
||||
.contains("nu::parser::operator_incompatible_types"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -72,5 +74,7 @@ fn concat_assign_runtime_type_mismatch() {
|
|||
$a ++= if true { 'str' }
|
||||
"#);
|
||||
|
||||
assert!(actual.err.contains("nu::shell::type_mismatch"));
|
||||
assert!(actual
|
||||
.err
|
||||
.contains("nu::shell::operator_incompatible_types"));
|
||||
}
|
||||
|
|
|
@ -107,7 +107,9 @@ fn error_reduce_fold_type_mismatch() {
|
|||
"echo a b c | reduce --fold 0 { |it, acc| $acc + $it }"
|
||||
));
|
||||
|
||||
assert!(actual.err.contains("mismatch"));
|
||||
assert!(actual
|
||||
.err
|
||||
.contains("nu::shell::operator_incompatible_types"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -1908,17 +1908,10 @@ mod range {
|
|||
|
||||
let _ = parse(&mut working_set, None, code.as_bytes(), true);
|
||||
|
||||
assert!(
|
||||
working_set.parse_errors.len() == 1,
|
||||
"Errors: {:?}",
|
||||
working_set.parse_errors
|
||||
);
|
||||
let err = &working_set.parse_errors[0].to_string();
|
||||
assert!(
|
||||
err.contains("range is not supported"),
|
||||
"Expected unsupported operation error, got {}",
|
||||
err
|
||||
);
|
||||
assert!(matches!(
|
||||
&working_set.parse_errors[..],
|
||||
[ParseError::OperatorUnsupportedType { .. }]
|
||||
),);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -167,7 +167,7 @@ fn const_binary_operator(#[case] inp: &[&str], #[case] expect: &str) {
|
|||
#[case(&["const x = 1 / 0", "$x"], "division by zero")]
|
||||
#[case(&["const x = 10 ** 10000000", "$x"], "pow operation overflowed")]
|
||||
#[case(&["const x = 2 ** 62 * 2", "$x"], "multiply operation overflowed")]
|
||||
#[case(&["const x = 1 ++ 0", "$x"], "doesn't support this value")]
|
||||
#[case(&["const x = 1 ++ 0", "$x"], "nu::parser::operator_unsupported_type")]
|
||||
fn const_operator_error(#[case] inp: &[&str], #[case] expect: &str) {
|
||||
let actual = nu!(&inp.join("; "));
|
||||
assert!(actual.err.contains(expect));
|
||||
|
|
|
@ -27,7 +27,7 @@ fn float_in_dec_range() -> TestResult {
|
|||
|
||||
#[test]
|
||||
fn non_number_in_range() -> TestResult {
|
||||
fail_test(r#"'a' in 1..3"#, "subset comparison is not supported")
|
||||
fail_test(r#"'a' in 1..3"#, "nu::parser::operator_incompatible_types")
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -73,10 +73,10 @@ fn invalid_not_regex_fails() -> TestResult {
|
|||
|
||||
#[test]
|
||||
fn regex_on_int_fails() -> TestResult {
|
||||
fail_test(r#"33 =~ foo"#, "is not supported")
|
||||
fail_test(r#"33 =~ foo"#, "nu::parser::operator_unsupported_type")
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn not_regex_on_int_fails() -> TestResult {
|
||||
fail_test(r#"33 !~ foo"#, "is not supported")
|
||||
fail_test(r#"33 !~ foo"#, "nu::parser::operator_unsupported_type")
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ fn string_in_string() -> TestResult {
|
|||
|
||||
#[test]
|
||||
fn non_string_in_string() -> TestResult {
|
||||
fail_test(r#"42 in 'abc'"#, "is not supported")
|
||||
fail_test(r#"42 in 'abc'"#, "nu::parser::operator_incompatible_types")
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -32,7 +32,7 @@ fn string_in_record() -> TestResult {
|
|||
fn non_string_in_record() -> TestResult {
|
||||
fail_test(
|
||||
r#"4 in ('{ "a": 13, "b": 14 }' | from json)"#,
|
||||
"mismatch during operation",
|
||||
"nu::shell::operator_incompatible_types",
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,10 @@ fn type_in_list_of_this_type() -> TestResult {
|
|||
|
||||
#[test]
|
||||
fn type_in_list_of_non_this_type() -> TestResult {
|
||||
fail_test(r#"'hello' in [41 42 43]"#, "is not supported")
|
||||
fail_test(
|
||||
r#"'hello' in [41 42 43]"#,
|
||||
"nu::parser::operator_incompatible_types",
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -779,7 +779,9 @@ fn filesize_math2() {
|
|||
100 / 10kb
|
||||
");
|
||||
|
||||
assert!(actual.err.contains("doesn't support"));
|
||||
assert!(actual
|
||||
.err
|
||||
.contains("nu::parser::operator_incompatible_types"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
Loading…
Reference in a new issue