Skip to content

Commit

Permalink
Auto merge of rust-lang#16256 - Urhengulas:ide-runnables-assert_eq, r…
Browse files Browse the repository at this point in the history
…=Veykril

internal: Only compare relevant parts in  `ide::{runnables,inlay_hints}` tests

This PR limits the data being compared. Therefore the tests should be more readable, as well as being more robust to changes to the data structure.

Part of rust-lang/rust-analyzer#14268.
  • Loading branch information
bors committed Jan 5, 2024
2 parents 2271b82 + f8ff4fb commit e53792b
Show file tree
Hide file tree
Showing 3 changed files with 226 additions and 1,584 deletions.
24 changes: 0 additions & 24 deletions crates/ide/src/inlay_hints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,6 @@ mod tests {
use hir::ClosureStyle;
use itertools::Itertools;
use test_utils::extract_annotations;
use text_edit::{TextRange, TextSize};

use crate::inlay_hints::{AdjustmentHints, AdjustmentHintsMode};
use crate::DiscriminantHints;
Expand Down Expand Up @@ -654,29 +653,6 @@ mod tests {
assert_eq!(expected, actual, "\nExpected:\n{expected:#?}\n\nActual:\n{actual:#?}");
}

#[track_caller]
pub(super) fn check_expect(config: InlayHintsConfig, ra_fixture: &str, expect: Expect) {
let (analysis, file_id) = fixture::file(ra_fixture);
let inlay_hints = analysis.inlay_hints(&config, file_id, None).unwrap();
expect.assert_debug_eq(&inlay_hints)
}

#[track_caller]
pub(super) fn check_expect_clear_loc(
config: InlayHintsConfig,
ra_fixture: &str,
expect: Expect,
) {
let (analysis, file_id) = fixture::file(ra_fixture);
let mut inlay_hints = analysis.inlay_hints(&config, file_id, None).unwrap();
inlay_hints.iter_mut().flat_map(|hint| &mut hint.label.parts).for_each(|hint| {
if let Some(loc) = &mut hint.linked_location {
loc.range = TextRange::empty(TextSize::from(0));
}
});
expect.assert_debug_eq(&inlay_hints)
}

/// Computes inlay hints for the fixture, applies all the provided text edits and then runs
/// expect test.
#[track_caller]
Expand Down
Loading

0 comments on commit e53792b

Please sign in to comment.