diff options
Diffstat (limited to 'crates/libanalysis')
-rw-r--r-- | crates/libanalysis/tests/tests.rs | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/crates/libanalysis/tests/tests.rs b/crates/libanalysis/tests/tests.rs index e05aa8895..5893efaf6 100644 --- a/crates/libanalysis/tests/tests.rs +++ b/crates/libanalysis/tests/tests.rs | |||
@@ -41,23 +41,21 @@ fn test_resolve_module() { | |||
41 | world.change_file(FileId(1), Some("mod foo;".to_string())); | 41 | world.change_file(FileId(1), Some("mod foo;".to_string())); |
42 | world.change_file(FileId(2), Some("".to_string())); | 42 | world.change_file(FileId(2), Some("".to_string())); |
43 | 43 | ||
44 | let snap = world.snapshot(FileMap(&[ | 44 | let snap = world.analysis(FileMap(&[ |
45 | (1, "/lib.rs"), | 45 | (1, "/lib.rs"), |
46 | (2, "/foo.rs"), | 46 | (2, "/foo.rs"), |
47 | ])); | 47 | ])); |
48 | let symbols = snap.approximately_resolve_symbol(FileId(1), 4.into()) | 48 | let symbols = snap.approximately_resolve_symbol(FileId(1), 4.into()); |
49 | .unwrap(); | ||
50 | assert_eq_dbg( | 49 | assert_eq_dbg( |
51 | r#"[(FileId(2), FileSymbol { name: "foo", node_range: [0; 0), kind: MODULE })]"#, | 50 | r#"[(FileId(2), FileSymbol { name: "foo", node_range: [0; 0), kind: MODULE })]"#, |
52 | &symbols, | 51 | &symbols, |
53 | ); | 52 | ); |
54 | 53 | ||
55 | let snap = world.snapshot(FileMap(&[ | 54 | let snap = world.analysis(FileMap(&[ |
56 | (1, "/lib.rs"), | 55 | (1, "/lib.rs"), |
57 | (2, "/foo/mod.rs") | 56 | (2, "/foo/mod.rs") |
58 | ])); | 57 | ])); |
59 | let symbols = snap.approximately_resolve_symbol(FileId(1), 4.into()) | 58 | let symbols = snap.approximately_resolve_symbol(FileId(1), 4.into()); |
60 | .unwrap(); | ||
61 | assert_eq_dbg( | 59 | assert_eq_dbg( |
62 | r#"[(FileId(2), FileSymbol { name: "foo", node_range: [0; 0), kind: MODULE })]"#, | 60 | r#"[(FileId(2), FileSymbol { name: "foo", node_range: [0; 0), kind: MODULE })]"#, |
63 | &symbols, | 61 | &symbols, |
@@ -69,11 +67,17 @@ fn test_unresolved_module_diagnostic() { | |||
69 | let mut world = WorldState::new(); | 67 | let mut world = WorldState::new(); |
70 | world.change_file(FileId(1), Some("mod foo;".to_string())); | 68 | world.change_file(FileId(1), Some("mod foo;".to_string())); |
71 | 69 | ||
72 | let snap = world.snapshot(FileMap(&[(1, "/lib.rs")])); | 70 | let snap = world.analysis(FileMap(&[(1, "/lib.rs")])); |
73 | let diagnostics = snap.diagnostics(FileId(1)).unwrap(); | 71 | let diagnostics = snap.diagnostics(FileId(1)); |
74 | assert_eq_dbg( | 72 | assert_eq_dbg( |
75 | r#"[(Diagnostic { range: [4; 7), msg: "unresolved module" }, | 73 | r#"[Diagnostic { |
76 | Some(QuickFix { fs_ops: [CreateFile { anchor: FileId(1), path: "../foo.rs" }] }))]"#, | 74 | message: "unresolved module", |
75 | range: [4; 7), | ||
76 | fix: Some(SourceChange { | ||
77 | label: "create module", | ||
78 | source_file_edits: [], | ||
79 | file_system_edits: [CreateFile { anchor: FileId(1), path: "../foo.rs" }], | ||
80 | cursor_position: None }) }]"#, | ||
77 | &diagnostics, | 81 | &diagnostics, |
78 | ); | 82 | ); |
79 | } | 83 | } |
@@ -83,8 +87,8 @@ fn test_unresolved_module_diagnostic_no_diag_for_inline_mode() { | |||
83 | let mut world = WorldState::new(); | 87 | let mut world = WorldState::new(); |
84 | world.change_file(FileId(1), Some("mod foo {}".to_string())); | 88 | world.change_file(FileId(1), Some("mod foo {}".to_string())); |
85 | 89 | ||
86 | let snap = world.snapshot(FileMap(&[(1, "/lib.rs")])); | 90 | let snap = world.analysis(FileMap(&[(1, "/lib.rs")])); |
87 | let diagnostics = snap.diagnostics(FileId(1)).unwrap(); | 91 | let diagnostics = snap.diagnostics(FileId(1)); |
88 | assert_eq_dbg( | 92 | assert_eq_dbg( |
89 | r#"[]"#, | 93 | r#"[]"#, |
90 | &diagnostics, | 94 | &diagnostics, |
@@ -97,7 +101,7 @@ fn test_resolve_parent_module() { | |||
97 | world.change_file(FileId(1), Some("mod foo;".to_string())); | 101 | world.change_file(FileId(1), Some("mod foo;".to_string())); |
98 | world.change_file(FileId(2), Some("".to_string())); | 102 | world.change_file(FileId(2), Some("".to_string())); |
99 | 103 | ||
100 | let snap = world.snapshot(FileMap(&[ | 104 | let snap = world.analysis(FileMap(&[ |
101 | (1, "/lib.rs"), | 105 | (1, "/lib.rs"), |
102 | (2, "/foo.rs"), | 106 | (2, "/foo.rs"), |
103 | ])); | 107 | ])); |