mirror of
https://github.com/oxalica/nil.git
synced 2025-12-23 09:19:49 +00:00
Improve backtrace in tests
This commit is contained in:
parent
893ae1f63f
commit
cf10fad204
3 changed files with 7 additions and 3 deletions
|
|
@ -1,9 +1,11 @@
|
|||
#[cfg(test)]
|
||||
macro_rules! define_check_assist {
|
||||
($handler:path) => {
|
||||
#[track_caller]
|
||||
fn check(fixture: &str, expect: ::expect_test::Expect) {
|
||||
crate::ide::assists::tests::check_assist($handler, fixture, expect);
|
||||
}
|
||||
#[track_caller]
|
||||
fn check_no(fixture: &str) {
|
||||
crate::ide::assists::tests::check_assist_no($handler, fixture);
|
||||
}
|
||||
|
|
@ -107,13 +109,14 @@ mod tests {
|
|||
use crate::SourceDatabase;
|
||||
use expect_test::Expect;
|
||||
|
||||
#[track_caller]
|
||||
fn try_apply_assist(
|
||||
handler: fn(&mut AssistsCtx) -> Option<()>,
|
||||
fixture: &str,
|
||||
) -> Option<String> {
|
||||
let (db, f) = TestDB::from_fixture(fixture).unwrap();
|
||||
assert_eq!(f.files().len(), 1);
|
||||
let frange = f.marker_single_range();
|
||||
let frange = f.unwrap_single_range_marker();
|
||||
let mut ctx = AssistsCtx::new(&db, frange);
|
||||
handler(&mut ctx);
|
||||
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ mod tests {
|
|||
|
||||
fn check(fixture: &str, expect: Expect) {
|
||||
let (db, f) = TestDB::from_fixture(fixture).unwrap();
|
||||
let frange = f.marker_single_range();
|
||||
let frange = f.unwrap_single_range_marker();
|
||||
let src = db.file_content(f[0].file_id);
|
||||
let got = super::expand_selection(&db, frange)
|
||||
.into_iter()
|
||||
|
|
|
|||
|
|
@ -168,7 +168,8 @@ impl Fixture {
|
|||
&self.markers
|
||||
}
|
||||
|
||||
pub fn marker_single_range(&self) -> FileRange {
|
||||
#[track_caller]
|
||||
pub fn unwrap_single_range_marker(&self) -> FileRange {
|
||||
match *self.markers() {
|
||||
[fpos] => FileRange::empty(fpos),
|
||||
[start, end] => FileRange::span(start, end),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue