Repository: nushell/nushell
File: crates/nu-cli/tests/completions/mod.rs (Rust)

Code before:
    match_suggestions(&expected, &suggestions);
}

#[rstest]
fn extern_custom_completion_long_flag_short(mut extern_completer: NuCompleter) {
    let suggestions = extern_completer.complete("spam -f ", 8);
    let expected: Vec<_> = vec!["cat", "dog", "eel"];
    match_suggestions(&expected, &suggestions);
}

#[rstest]
fn extern_custom_completion_short_flag(mut extern_completer: NuCompleter) {
    let suggestions = extern_completer.complete("spam -b ", 8);
    let expected: Vec<_> = vec!["cat", "dog", "eel"];
    match_suggestions(&expected, &suggestions);
}

/// When we're completing the flag name itself, not its value,
/// custom completions should not be used
#[rstest]
fn custom_completion_flag_name_not_value(mut extern_completer: NuCompleter) {
    let suggestions = extern_completer.complete("spam --f", 8);
    assert!(
        suggestions.iter().any(|s| s.value == "--foo"),
        "Should contain --foo flag"
    );
    match_suggestions(&vec!["--foo"], &suggestions);
    // Also test with partial short flag
    let suggestions = extern_completer.complete("spam -f", 7);
    match_suggestions(&vec!["-f"], &suggestions);
}

#[rstest]
fn extern_complete_flags(mut extern_completer: NuCompleter) {
    let suggestions = extern_completer.complete("spam -", 6);
    let expected: Vec<_> = vec!["--foo", "-b", "-f"];
    match_suggestions(&expected, &suggestions);
}

#[rstest]
fn custom_completer_triggers_cursor_before_word(mut custom_completer: NuCompleter) {
    let suggestions = custom_completer.complete("cmd foo  bar", 8);
    let expected: Vec<_> = vec!["cmd", "foo", ""];
    match_suggestions(&expected, &suggestions);
}

#[rstest]
fn custom_completer_triggers_cursor_on_word_left_boundary(mut custom_completer: NuCompleter) {
    let suggestions = custom_completer.complete("cmd foo bar", 8);
    let expected: Vec<_> = vec!["cmd", "foo", ""];
    match_suggestions(&expected, &suggestions);

Review comment (suggestion):
This assertion should be unnecessary, since there's a `match_suggestions()` call right after
```suggestion
```

Code after:
    match_suggestions(&expected, &suggestions);
}

#[rstest]
fn extern_custom_completion_long_flag_short(mut extern_completer: NuCompleter) {
    let suggestions = extern_completer.complete("spam -f ", 8);
    let expected: Vec<_> = vec!["cat", "dog", "eel"];
    match_suggestions(&expected, &suggestions);
}

#[rstest]
fn extern_custom_completion_short_flag(mut extern_completer: NuCompleter) {
    let suggestions = extern_completer.complete("spam -b ", 8);
    let expected: Vec<_> = vec!["cat", "dog", "eel"];
    match_suggestions(&expected, &suggestions);
}

/// When we're completing the flag name itself, not its value,
/// custom completions should not be used
#[rstest]
fn custom_completion_flag_name_not_value(mut extern_completer: NuCompleter) {
    let suggestions = extern_completer.complete("spam --f", 8);
    match_suggestions(&vec!["--foo"], &suggestions);
    // Also test with partial short flag
    let suggestions = extern_completer.complete("spam -f", 7);
    match_suggestions(&vec!["-f"], &suggestions);
}

#[rstest]
fn extern_complete_flags(mut extern_completer: NuCompleter) {
    let suggestions = extern_completer.complete("spam -", 6);
    let expected: Vec<_> = vec!["--foo", "-b", "-f"];
    match_suggestions(&expected, &suggestions);
}

#[rstest]
fn custom_completer_triggers_cursor_before_word(mut custom_completer: NuCompleter) {
    let suggestions = custom_completer.complete("cmd foo  bar", 8);
    let expected: Vec<_> = vec!["cmd", "foo", ""];
    match_suggestions(&expected, &suggestions);
}

#[rstest]
fn custom_completer_triggers_cursor_on_word_left_boundary(mut custom_completer: NuCompleter) {
    let suggestions = custom_completer.complete("cmd foo bar", 8);
    let expected: Vec<_> = vec!["cmd", "foo", ""];
    match_suggestions(&expected, &suggestions);
}

#[rstest]
fn custom_completer_triggers_cursor_next_to_word(mut custom_completer: NuCompleter) {