Skip to content

Commit 156f907

Browse files
authored
Use check_count! instead of multiple check! in separate scopes
Changes are based on the review feedback by Veykril.
1 parent 0cc079f commit 156f907

File tree

1 file changed

+69
-78
lines changed
  • crates/ide_db/src/imports/insert_use

1 file changed

+69
-78
lines changed

crates/ide_db/src/imports/insert_use/tests.rs

Lines changed: 69 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -302,108 +302,99 @@ fn main() {}",
302302

303303
#[test]
304304
fn insert_empty_file() {
305-
{
306-
// Default configuration
307-
cov_mark::check!(insert_empty_file);
308-
// empty files will get two trailing newlines
309-
// this is due to the test case insert_no_imports above
310-
check_crate(
311-
"foo::bar",
312-
"",
313-
r"use foo::bar;
305+
cov_mark::check_count!(insert_empty_file, 2);
306+
307+
// Default configuration
308+
// empty files will get two trailing newlines
309+
// this is due to the test case insert_no_imports above
310+
check_crate(
311+
"foo::bar",
312+
"",
313+
r"use foo::bar;
314314
315315
",
316-
);
317-
}
318-
{
319-
// "not group" configuration
320-
cov_mark::check!(insert_empty_file);
321-
check_with_config(
322-
"use external_crate2::bar::A",
323-
r"",
324-
r"use external_crate2::bar::A;
316+
);
317+
318+
// "not group" configuration
319+
check_with_config(
320+
"use external_crate2::bar::A",
321+
r"",
322+
r"use external_crate2::bar::A;
325323
326324
",
327-
&InsertUseConfig {
328-
granularity: ImportGranularity::Item,
329-
enforce_granularity: true,
330-
prefix_kind: PrefixKind::Plain,
331-
group: false,
332-
skip_glob_imports: true,
333-
},
334-
);
335-
}
325+
&InsertUseConfig {
326+
granularity: ImportGranularity::Item,
327+
enforce_granularity: true,
328+
prefix_kind: PrefixKind::Plain,
329+
group: false,
330+
skip_glob_imports: true,
331+
},
332+
);
336333
}
337334

338335
#[test]
339336
fn insert_empty_module() {
340-
{
341-
// Default configuration
342-
cov_mark::check!(insert_empty_module);
343-
check(
344-
"foo::bar",
345-
r"
337+
cov_mark::check_count!(insert_empty_module, 2);
338+
339+
// Default configuration
340+
check(
341+
"foo::bar",
342+
r"
346343
mod x {$0}
347344
",
348-
r"
345+
r"
349346
mod x {
350347
use foo::bar;
351348
}
352349
",
353-
ImportGranularity::Item,
354-
);
355-
}
356-
{
357-
// "not group" configuration
358-
cov_mark::check!(insert_empty_module);
359-
check_with_config(
360-
"foo::bar",
361-
r"mod x {$0}",
362-
r"mod x {
350+
ImportGranularity::Item,
351+
);
352+
353+
// "not group" configuration
354+
check_with_config(
355+
"foo::bar",
356+
r"mod x {$0}",
357+
r"mod x {
363358
use foo::bar;
364359
}",
365-
&InsertUseConfig {
366-
granularity: ImportGranularity::Item,
367-
enforce_granularity: true,
368-
prefix_kind: PrefixKind::Plain,
369-
group: false,
370-
skip_glob_imports: true,
371-
},
372-
);
373-
}
360+
&InsertUseConfig {
361+
granularity: ImportGranularity::Item,
362+
enforce_granularity: true,
363+
prefix_kind: PrefixKind::Plain,
364+
group: false,
365+
skip_glob_imports: true,
366+
},
367+
);
374368
}
375369

376370
#[test]
377371
fn insert_after_inner_attr() {
378-
{
379-
// Default configuration
380-
cov_mark::check!(insert_empty_inner_attr);
381-
check_crate(
382-
"foo::bar",
383-
r"#![allow(unused_imports)]",
384-
r"#![allow(unused_imports)]
372+
cov_mark::check_count!(insert_empty_inner_attr, 2);
373+
374+
// Default configuration
375+
check_crate(
376+
"foo::bar",
377+
r"#![allow(unused_imports)]",
378+
r"#![allow(unused_imports)]
385379
386380
use foo::bar;",
387-
);
388-
}
389-
{
390-
// "not group" configuration
391-
cov_mark::check!(insert_empty_inner_attr);
392-
check_with_config(
393-
"foo::bar",
394-
r"#![allow(unused_imports)]",
395-
r"#![allow(unused_imports)]
381+
);
382+
383+
// "not group" configuration
384+
check_with_config(
385+
"foo::bar",
386+
r"#![allow(unused_imports)]",
387+
r"#![allow(unused_imports)]
396388
397389
use foo::bar;",
398-
&InsertUseConfig {
399-
granularity: ImportGranularity::Item,
400-
enforce_granularity: true,
401-
prefix_kind: PrefixKind::Plain,
402-
group: false,
403-
skip_glob_imports: true,
404-
},
405-
);
406-
}
390+
&InsertUseConfig {
391+
granularity: ImportGranularity::Item,
392+
enforce_granularity: true,
393+
prefix_kind: PrefixKind::Plain,
394+
group: false,
395+
skip_glob_imports: true,
396+
},
397+
);
407398
}
408399

409400
#[test]

0 commit comments

Comments
 (0)