mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 13:51:31 +00:00
move tests to where they belong
This commit is contained in:
parent
e9af69d9db
commit
309716cffe
4 changed files with 32 additions and 44 deletions
|
@ -560,6 +560,7 @@ fn unresolved_module_diagnostics() {
|
||||||
//- /lib.rs
|
//- /lib.rs
|
||||||
mod foo;
|
mod foo;
|
||||||
mod bar;
|
mod bar;
|
||||||
|
mod baz {}
|
||||||
//- /foo.rs
|
//- /foo.rs
|
||||||
",
|
",
|
||||||
)
|
)
|
||||||
|
|
|
@ -152,6 +152,9 @@ fn check_struct_shorthand_initialization(
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use test_utils::assert_eq_text;
|
use test_utils::assert_eq_text;
|
||||||
|
use insta::assert_debug_snapshot_matches;
|
||||||
|
|
||||||
|
use crate::mock_analysis::single_file;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
|
@ -180,6 +183,34 @@ mod tests {
|
||||||
assert_eq_text!(after, &actual);
|
assert_eq_text!(after, &actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_unresolved_module_diagnostic() {
|
||||||
|
let (analysis, file_id) = single_file("mod foo;");
|
||||||
|
let diagnostics = analysis.diagnostics(file_id).unwrap();
|
||||||
|
assert_debug_snapshot_matches!(diagnostics, @r####"[
|
||||||
|
Diagnostic {
|
||||||
|
message: "unresolved module",
|
||||||
|
range: [0; 8),
|
||||||
|
fix: Some(
|
||||||
|
SourceChange {
|
||||||
|
label: "create module",
|
||||||
|
source_file_edits: [],
|
||||||
|
file_system_edits: [
|
||||||
|
CreateFile {
|
||||||
|
source_root: SourceRootId(
|
||||||
|
0
|
||||||
|
),
|
||||||
|
path: "foo.rs"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
cursor_position: None
|
||||||
|
}
|
||||||
|
),
|
||||||
|
severity: Error
|
||||||
|
}
|
||||||
|
]"####);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_check_unnecessary_braces_in_use_statement() {
|
fn test_check_unnecessary_braces_in_use_statement() {
|
||||||
check_not_applicable(
|
check_not_applicable(
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
use insta::assert_debug_snapshot_matches;
|
|
||||||
use ra_ide_api::{
|
use ra_ide_api::{
|
||||||
mock_analysis::{single_file, single_file_with_position, single_file_with_range, MockAnalysis},
|
mock_analysis::{single_file, single_file_with_position, single_file_with_range, MockAnalysis},
|
||||||
AnalysisChange, CrateGraph, Edition::Edition2018, Query, NavigationTarget,
|
AnalysisChange, CrateGraph, Edition::Edition2018, Query, NavigationTarget,
|
||||||
|
@ -6,21 +5,6 @@ use ra_ide_api::{
|
||||||
};
|
};
|
||||||
use ra_syntax::SmolStr;
|
use ra_syntax::SmolStr;
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_unresolved_module_diagnostic() {
|
|
||||||
let (analysis, file_id) = single_file("mod foo;");
|
|
||||||
let diagnostics = analysis.diagnostics(file_id).unwrap();
|
|
||||||
assert_debug_snapshot_matches!("unresolved_module_diagnostic", &diagnostics);
|
|
||||||
}
|
|
||||||
|
|
||||||
// FIXME: move this test to hir
|
|
||||||
#[test]
|
|
||||||
fn test_unresolved_module_diagnostic_no_diag_for_inline_mode() {
|
|
||||||
let (analysis, file_id) = single_file("mod foo {}");
|
|
||||||
let diagnostics = analysis.diagnostics(file_id).unwrap();
|
|
||||||
assert!(diagnostics.is_empty());
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_resolve_crate_root() {
|
fn test_resolve_crate_root() {
|
||||||
let mock = MockAnalysis::with_files(
|
let mock = MockAnalysis::with_files(
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
---
|
|
||||||
created: "2019-01-22T14:45:01.486985900+00:00"
|
|
||||||
creator: insta@0.4.0
|
|
||||||
expression: "&diagnostics"
|
|
||||||
source: "crates\\ra_ide_api\\tests\\test\\main.rs"
|
|
||||||
---
|
|
||||||
[
|
|
||||||
Diagnostic {
|
|
||||||
message: "unresolved module",
|
|
||||||
range: [0; 8),
|
|
||||||
fix: Some(
|
|
||||||
SourceChange {
|
|
||||||
label: "create module",
|
|
||||||
source_file_edits: [],
|
|
||||||
file_system_edits: [
|
|
||||||
CreateFile {
|
|
||||||
source_root: SourceRootId(
|
|
||||||
0
|
|
||||||
),
|
|
||||||
path: "foo.rs"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
cursor_position: None
|
|
||||||
}
|
|
||||||
),
|
|
||||||
severity: Error
|
|
||||||
}
|
|
||||||
]
|
|
Loading…
Add table
Add a link
Reference in a new issue