@@ -368,7 +368,7 @@ mod tests {
368
368
use std:: collections:: HashMap ;
369
369
370
370
use expect_test:: { expect, Expect } ;
371
- use ide_db:: source_change:: FileSystemEdit ;
371
+ use ide_db:: source_change:: { FileSystemEdit , SourceChange } ;
372
372
use stdx:: trim_indent;
373
373
use test_utils:: assert_eq_text;
374
374
use text_edit:: TextEdit ;
@@ -421,39 +421,7 @@ mod tests {
421
421
let ( analysis, position) = fixture:: position ( ra_fixture) ;
422
422
let source_change =
423
423
analysis. rename ( position, new_name) . unwrap ( ) . expect ( "Expect returned a RenameError" ) ;
424
-
425
- // file_id 1:
426
- // source_file_edits:
427
- // - Indel { insert: "foo2", delete: 4..7 }
428
- //
429
- // file_id 2:
430
- // file_system_edits:
431
- // MoveFile AnchoredPathBuf { anchor: FileId(2), path: "foo2.rs", }
432
-
433
- let source_file_edits = source_change
434
- . source_file_edits
435
- . into_iter ( )
436
- . map ( |( a, ( b, _) ) | ( a, b. into_iter ( ) . collect :: < Vec < _ > > ( ) ) )
437
- . collect :: < HashMap < _ , _ > > ( ) ;
438
-
439
- let file_system_edits = source_change
440
- . file_system_edits
441
- . into_iter ( )
442
- . map ( |a| {
443
- let id = match & a {
444
- FileSystemEdit :: CreateFile { .. } => unreachable ! ( ) ,
445
- FileSystemEdit :: MoveFile { src, .. } => src,
446
- FileSystemEdit :: MoveDir { src_id, .. } => src_id,
447
- } ;
448
- ( id. clone ( ) , a)
449
- } )
450
- . collect :: < HashMap < _ , _ > > ( ) ;
451
-
452
- let b = format ! (
453
- "source_file_edits: {:#?}\n file_system_edits: {:#?}" ,
454
- source_file_edits, file_system_edits
455
- ) ;
456
- expect. assert_eq ( & b)
424
+ expect. assert_eq ( & filter_expect ( source_change) )
457
425
}
458
426
459
427
fn check_expect_will_rename_file ( new_name : & str , ra_fixture : & str , expect : Expect ) {
@@ -462,7 +430,7 @@ mod tests {
462
430
. will_rename_file ( position. file_id , new_name)
463
431
. unwrap ( )
464
432
. expect ( "Expect returned a RenameError" ) ;
465
- expect. assert_debug_eq ( & source_change)
433
+ expect. assert_eq ( & filter_expect ( source_change) )
466
434
}
467
435
468
436
fn check_prepare ( ra_fixture : & str , expect : Expect ) {
@@ -479,6 +447,32 @@ mod tests {
479
447
} ;
480
448
}
481
449
450
+ fn filter_expect ( source_change : SourceChange ) -> String {
451
+ let source_file_edits = source_change
452
+ . source_file_edits
453
+ . into_iter ( )
454
+ . map ( |( id, ( text_edit, _) ) | ( id, text_edit. into_iter ( ) . collect :: < Vec < _ > > ( ) ) )
455
+ . collect :: < HashMap < _ , _ > > ( ) ;
456
+
457
+ let file_system_edits = source_change
458
+ . file_system_edits
459
+ . into_iter ( )
460
+ . map ( |file_system_edit| {
461
+ let id = match & file_system_edit {
462
+ FileSystemEdit :: CreateFile { .. } => unreachable ! ( ) ,
463
+ FileSystemEdit :: MoveFile { src, .. } => src,
464
+ FileSystemEdit :: MoveDir { src_id, .. } => src_id,
465
+ } ;
466
+ ( id. clone ( ) , file_system_edit)
467
+ } )
468
+ . collect :: < HashMap < _ , _ > > ( ) ;
469
+
470
+ format ! (
471
+ "source_file_edits: {:#?}\n file_system_edits: {:#?}" ,
472
+ source_file_edits, file_system_edits
473
+ )
474
+ }
475
+
482
476
#[ test]
483
477
fn test_prepare_rename_namelikes ( ) {
484
478
check_prepare ( r"fn name$0<'lifetime>() {}" , expect ! [ [ r#"3..7: name"# ] ] ) ;
0 commit comments