mirror of
https://github.com/nushell/nushell.git
synced 2025-08-10 04:17:46 +02:00
Improve "Did you mean?" suggestions (#6579)
* Copy lev_distance.rs from the rust compiler * Minor changes to code from rust compiler * "Did you mean" suggestions: test instrumented to generate markdown report * Did you mean suggestions: delete test instrumentation * Fix tests * Fix test `foo` has a genuine match: `for` * Improve tests
This commit is contained in:
@ -137,8 +137,8 @@ fn errors_fetching_by_column_not_present() {
|
||||
sandbox.with_files(vec![FileWithContent(
|
||||
"sample.toml",
|
||||
r#"
|
||||
[taconushell]
|
||||
sentence_words = ["Yo", "quiero", "taconushell"]
|
||||
[tacos]
|
||||
sentence_words = ["Yo", "quiero", "tacos"]
|
||||
[pizzanushell]
|
||||
sentence-words = ["I", "want", "pizza"]
|
||||
"#,
|
||||
@ -153,7 +153,7 @@ fn errors_fetching_by_column_not_present() {
|
||||
));
|
||||
|
||||
assert!(actual.err.contains("Name not found"),);
|
||||
assert!(actual.err.contains("did you mean 'taconushell'"),);
|
||||
assert!(actual.err.contains("did you mean 'tacos'"),);
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -194,7 +194,7 @@ fn source_env_eval_export_env_hide() {
|
||||
|
||||
let actual = nu!(cwd: dirs.test(), pipeline(&inp.join("; ")));
|
||||
|
||||
assert!(actual.err.contains("did you mean"));
|
||||
assert!(actual.err.contains("cannot find column"));
|
||||
})
|
||||
}
|
||||
|
||||
@ -275,21 +275,21 @@ fn source_env_is_scoped() {
|
||||
sandbox.with_files(vec![FileWithContentToBeTrimmed(
|
||||
"spam.nu",
|
||||
r#"
|
||||
def foo [] { 'foo' }
|
||||
alias bar = 'bar'
|
||||
def no-name-similar-to-this [] { 'no-name-similar-to-this' }
|
||||
alias nor-similar-to-this = 'nor-similar-to-this'
|
||||
"#,
|
||||
)]);
|
||||
|
||||
let inp = &[r#"source-env spam.nu"#, r#"foo"#];
|
||||
let inp = &[r#"source-env spam.nu"#, r#"no-name-similar-to-this"#];
|
||||
|
||||
let actual = nu!(cwd: dirs.test(), pipeline(&inp.join("; ")));
|
||||
|
||||
assert!(actual.err.contains("did you mean"));
|
||||
assert!(actual.err.contains("can't run executable"));
|
||||
|
||||
let inp = &[r#"source-env spam.nu"#, r#"bar"#];
|
||||
let inp = &[r#"source-env spam.nu"#, r#"nor-similar-to-this"#];
|
||||
|
||||
let actual = nu!(cwd: dirs.test(), pipeline(&inp.join("; ")));
|
||||
|
||||
assert!(actual.err.contains("did you mean"));
|
||||
assert!(actual.err.contains("can't run executable"));
|
||||
})
|
||||
}
|
||||
|
@ -181,7 +181,7 @@ fn from_error() {
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "nu::shell::name_not_found");
|
||||
assert_eq!(actual.out, "nu::shell::column_not_found");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -97,7 +97,7 @@ fn use_eval_export_env_hide() {
|
||||
|
||||
let actual = nu!(cwd: dirs.test(), pipeline(&inp.join("; ")));
|
||||
|
||||
assert!(actual.err.contains("did you mean"));
|
||||
assert!(actual.err.contains("cannot find column"));
|
||||
})
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user