Fix typos and use more idiomatic assertions (#7755)

I have changed `assert!(a == b)` calls to `assert_eq!(a, b)`, which give
better error messages. Similarly for `assert!(a != b)` and
`assert_ne!(a, b)`. Basically all instances were comparing primitives
(string slices or integers), so there is no loss of generality from
special-case macros,

I have also fixed a number of typos in comments, variable names, and a
few user-facing messages.
This commit is contained in:
Anton
2023-01-15 05:03:32 +03:00
committed by GitHub
parent b0b0482d71
commit 7221eb7f39
32 changed files with 143 additions and 143 deletions

View File

@ -9,7 +9,7 @@ fn for_auto_print_in_each_iteration() {
echo 1
}"#
);
// Note: nu! macro auto repalce "\n" and "\r\n" with ""
// Note: nu! macro auto replace "\n" and "\r\n" with ""
// so our output will be `11`
// that's ok, our main concern is it auto print value in each iteration.
assert_eq!(actual.out, "11");
@ -25,7 +25,7 @@ fn for_break_on_external_failed() {
nu --testbin fail
}"#
);
// Note: nu! macro auto repalce "\n" and "\r\n" with ""
// Note: nu! macro auto replace "\n" and "\r\n" with ""
// so our output will be `1`
assert_eq!(actual.out, "1");
}

View File

@ -15,7 +15,7 @@ fn loop_auto_print_in_each_iteration() {
echo 1
}"#
);
// Note: nu! macro auto repalce "\n" and "\r\n" with ""
// Note: nu! macro auto replace "\n" and "\r\n" with ""
// so our output will be `111`
// that's ok, our main concern is it auto print value in each iteration.
assert_eq!(actual.out, "111");
@ -37,7 +37,7 @@ fn loop_break_on_external_failed() {
nu --testbin fail;
}"#
);
// Note: nu! macro auto repalce "\n" and "\r\n" with ""
// Note: nu! macro auto replace "\n" and "\r\n" with ""
// so our output will be `1`.
assert_eq!(actual.out, "1");
}

View File

@ -479,25 +479,25 @@ fn can_list_system_folder() {
cwd: "C:\\Windows\\System32", pipeline(
r#"ls Configuration* | where name == "Configuration" | get size.0"#
));
assert!(file_size.out.trim() != "");
assert_ne!(file_size.out.trim(), "");
let file_modified = nu!(
cwd: "C:\\Windows\\System32", pipeline(
r#"ls Configuration* | where name == "Configuration" | get modified.0"#
));
assert!(file_modified.out.trim() != "");
assert_ne!(file_modified.out.trim(), "");
let file_accessed = nu!(
cwd: "C:\\Windows\\System32", pipeline(
r#"ls -l Configuration* | where name == "Configuration" | get accessed.0"#
));
assert!(file_accessed.out.trim() != "");
assert_ne!(file_accessed.out.trim(), "");
let file_created = nu!(
cwd: "C:\\Windows\\System32", pipeline(
r#"ls -l Configuration* | where name == "Configuration" | get created.0"#
));
assert!(file_created.out.trim() != "");
assert_ne!(file_created.out.trim(), "");
let ls_with_filter = nu!(
cwd: "C:\\Windows\\System32", pipeline(

View File

@ -41,7 +41,7 @@ fn port_with_already_usage() {
return;
}
}
panic!("already check port report AddrInUse for seveval times, but still failed.");
panic!("already check port report AddrInUse for several times, but still failed.");
}
#[test]

View File

@ -34,7 +34,7 @@ mod simple {
}
#[test]
fn double_open_curly_evalutes_to_a_single_curly() {
fn double_open_curly_evaluates_to_a_single_curly() {
Playground::setup("parse_test_regex_2", |dirs, _sandbox| {
let actual = nu!(
cwd: dirs.test(), pipeline(

View File

@ -41,9 +41,9 @@ fn table_expand_0() {
);
}
// I am not sure whether the test is platform depent, cause we don't set a term_width on our own
// I am not sure whether the test is platform dependent, cause we don't set a term_width on our own
#[test]
fn table_expand_exeed_overlap_0() {
fn table_expand_exceed_overlap_0() {
// no expand
let actual = nu!(r#"[[a b, c]; [xxxxxxxxxxxxxxxxxxxxxx 2 3] [4 5 [1 2 3]]] | table --expand"#);

View File

@ -16,7 +16,7 @@ fn while_auto_print_in_each_iteration() {
cwd: ".",
"mut total = 0; while $total < 2 { $total = $total + 1; echo 1 }"
);
// Note: nu! macro auto repalce "\n" and "\r\n" with ""
// Note: nu! macro auto replace "\n" and "\r\n" with ""
// so our output will be `11`
// that's ok, our main concern is it auto print value in each iteration.
assert_eq!(actual.out, "11");
@ -28,7 +28,7 @@ fn while_break_on_external_failed() {
cwd: ".",
"mut total = 0; while $total < 2 { $total = $total + 1; echo 1; nu --testbin fail }"
);
// Note: nu! macro auto repalce "\n" and "\r\n" with ""
// Note: nu! macro auto replace "\n" and "\r\n" with ""
// so our output will be `1`
assert_eq!(actual.out, "1");
}