diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-01-15 11:18:56 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-01-15 11:18:56 +0000 |
commit | f6f2e89e7ac9c4afbda11bade21f902c552fbba2 (patch) | |
tree | 07e0ffe10b57fe55f6586707ae1776d47b77f6e0 /crates/ra_ide_api/tests/test | |
parent | e8e82ce032f8678929b015e6f70ac060bb2cf94c (diff) | |
parent | d79a9b17dc4fb132443aa4ec1ca0ab278d2a217c (diff) |
Merge #546
546: replace `assert_dbg_eq` with Insta r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_ide_api/tests/test')
-rw-r--r-- | crates/ra_ide_api/tests/test/main.rs | 20 | ||||
-rw-r--r-- | crates/ra_ide_api/tests/test/runnables.rs | 109 | ||||
-rw-r--r-- | crates/ra_ide_api/tests/test/snapshots/test__unresolved_module_diagnostic.snap | 26 |
3 files changed, 30 insertions, 125 deletions
diff --git a/crates/ra_ide_api/tests/test/main.rs b/crates/ra_ide_api/tests/test/main.rs index 7dc1dba73..2b863aedf 100644 --- a/crates/ra_ide_api/tests/test/main.rs +++ b/crates/ra_ide_api/tests/test/main.rs | |||
@@ -1,7 +1,6 @@ | |||
1 | mod runnables; | ||
2 | |||
3 | use ra_syntax::TextRange; | 1 | use ra_syntax::TextRange; |
4 | use test_utils::{assert_eq_dbg, assert_eq_text}; | 2 | use test_utils::assert_eq_text; |
3 | use insta::assert_debug_snapshot_matches; | ||
5 | 4 | ||
6 | use ra_ide_api::{ | 5 | use ra_ide_api::{ |
7 | mock_analysis::{single_file, single_file_with_position, MockAnalysis}, | 6 | mock_analysis::{single_file, single_file_with_position, MockAnalysis}, |
@@ -12,18 +11,7 @@ use ra_ide_api::{ | |||
12 | fn test_unresolved_module_diagnostic() { | 11 | fn test_unresolved_module_diagnostic() { |
13 | let (analysis, file_id) = single_file("mod foo;"); | 12 | let (analysis, file_id) = single_file("mod foo;"); |
14 | let diagnostics = analysis.diagnostics(file_id).unwrap(); | 13 | let diagnostics = analysis.diagnostics(file_id).unwrap(); |
15 | assert_eq_dbg( | 14 | assert_debug_snapshot_matches!("unresolved_module_diagnostic", &diagnostics); |
16 | r#"[Diagnostic { | ||
17 | message: "unresolved module", | ||
18 | range: [4; 7), | ||
19 | fix: Some(SourceChange { | ||
20 | label: "create module", | ||
21 | source_file_edits: [], | ||
22 | file_system_edits: [CreateFile { source_root: SourceRootId(0), path: "foo.rs" }], | ||
23 | cursor_position: None }), | ||
24 | severity: Error }]"#, | ||
25 | &diagnostics, | ||
26 | ); | ||
27 | } | 15 | } |
28 | 16 | ||
29 | // FIXME: move this test to hir | 17 | // FIXME: move this test to hir |
@@ -31,7 +19,7 @@ fn test_unresolved_module_diagnostic() { | |||
31 | fn test_unresolved_module_diagnostic_no_diag_for_inline_mode() { | 19 | fn test_unresolved_module_diagnostic_no_diag_for_inline_mode() { |
32 | let (analysis, file_id) = single_file("mod foo {}"); | 20 | let (analysis, file_id) = single_file("mod foo {}"); |
33 | let diagnostics = analysis.diagnostics(file_id).unwrap(); | 21 | let diagnostics = analysis.diagnostics(file_id).unwrap(); |
34 | assert_eq_dbg(r#"[]"#, &diagnostics); | 22 | assert!(diagnostics.is_empty()); |
35 | } | 23 | } |
36 | 24 | ||
37 | #[test] | 25 | #[test] |
diff --git a/crates/ra_ide_api/tests/test/runnables.rs b/crates/ra_ide_api/tests/test/runnables.rs deleted file mode 100644 index da8d5e0d5..000000000 --- a/crates/ra_ide_api/tests/test/runnables.rs +++ /dev/null | |||
@@ -1,109 +0,0 @@ | |||
1 | use test_utils::assert_eq_dbg; | ||
2 | |||
3 | use ra_ide_api::mock_analysis::analysis_and_position; | ||
4 | |||
5 | #[test] | ||
6 | fn test_runnables() { | ||
7 | let (analysis, pos) = analysis_and_position( | ||
8 | r#" | ||
9 | //- /lib.rs | ||
10 | <|> //empty | ||
11 | fn main() {} | ||
12 | |||
13 | #[test] | ||
14 | fn test_foo() {} | ||
15 | |||
16 | #[test] | ||
17 | #[ignore] | ||
18 | fn test_foo() {} | ||
19 | "#, | ||
20 | ); | ||
21 | let runnables = analysis.runnables(pos.file_id).unwrap(); | ||
22 | assert_eq_dbg( | ||
23 | r#"[Runnable { range: [1; 21), kind: Bin }, | ||
24 | Runnable { range: [22; 46), kind: Test { name: "test_foo" } }, | ||
25 | Runnable { range: [47; 81), kind: Test { name: "test_foo" } }]"#, | ||
26 | &runnables, | ||
27 | ) | ||
28 | } | ||
29 | |||
30 | #[test] | ||
31 | fn test_runnables_module() { | ||
32 | let (analysis, pos) = analysis_and_position( | ||
33 | r#" | ||
34 | //- /lib.rs | ||
35 | <|> //empty | ||
36 | mod test_mod { | ||
37 | #[test] | ||
38 | fn test_foo1() {} | ||
39 | } | ||
40 | "#, | ||
41 | ); | ||
42 | let runnables = analysis.runnables(pos.file_id).unwrap(); | ||
43 | assert_eq_dbg( | ||
44 | r#"[Runnable { range: [1; 59), kind: TestMod { path: "test_mod" } }, | ||
45 | Runnable { range: [28; 57), kind: Test { name: "test_foo1" } }]"#, | ||
46 | &runnables, | ||
47 | ) | ||
48 | } | ||
49 | |||
50 | #[test] | ||
51 | fn test_runnables_one_depth_layer_module() { | ||
52 | let (analysis, pos) = analysis_and_position( | ||
53 | r#" | ||
54 | //- /lib.rs | ||
55 | <|> //empty | ||
56 | mod foo { | ||
57 | mod test_mod { | ||
58 | #[test] | ||
59 | fn test_foo1() {} | ||
60 | } | ||
61 | } | ||
62 | "#, | ||
63 | ); | ||
64 | let runnables = analysis.runnables(pos.file_id).unwrap(); | ||
65 | assert_eq_dbg( | ||
66 | r#"[Runnable { range: [23; 85), kind: TestMod { path: "foo::test_mod" } }, | ||
67 | Runnable { range: [46; 79), kind: Test { name: "test_foo1" } }]"#, | ||
68 | &runnables, | ||
69 | ) | ||
70 | } | ||
71 | |||
72 | #[test] | ||
73 | fn test_runnables_multiple_depth_module() { | ||
74 | let (analysis, pos) = analysis_and_position( | ||
75 | r#" | ||
76 | //- /lib.rs | ||
77 | <|> //empty | ||
78 | mod foo { | ||
79 | mod bar { | ||
80 | mod test_mod { | ||
81 | #[test] | ||
82 | fn test_foo1() {} | ||
83 | } | ||
84 | } | ||
85 | } | ||
86 | "#, | ||
87 | ); | ||
88 | let runnables = analysis.runnables(pos.file_id).unwrap(); | ||
89 | assert_eq_dbg( | ||
90 | r#"[Runnable { range: [41; 115), kind: TestMod { path: "foo::bar::test_mod" } }, | ||
91 | Runnable { range: [68; 105), kind: Test { name: "test_foo1" } }]"#, | ||
92 | &runnables, | ||
93 | ) | ||
94 | } | ||
95 | |||
96 | #[test] | ||
97 | fn test_runnables_no_test_function_in_module() { | ||
98 | let (analysis, pos) = analysis_and_position( | ||
99 | r#" | ||
100 | //- /lib.rs | ||
101 | <|> //empty | ||
102 | mod test_mod { | ||
103 | fn foo1() {} | ||
104 | } | ||
105 | "#, | ||
106 | ); | ||
107 | let runnables = analysis.runnables(pos.file_id).unwrap(); | ||
108 | assert_eq_dbg(r#"[]"#, &runnables) | ||
109 | } | ||
diff --git a/crates/ra_ide_api/tests/test/snapshots/test__unresolved_module_diagnostic.snap b/crates/ra_ide_api/tests/test/snapshots/test__unresolved_module_diagnostic.snap new file mode 100644 index 000000000..1b41e2b00 --- /dev/null +++ b/crates/ra_ide_api/tests/test/snapshots/test__unresolved_module_diagnostic.snap | |||
@@ -0,0 +1,26 @@ | |||
1 | Created: 2019-01-15T11:15:20.891129945+00:00 | ||
2 | Creator: [email protected] | ||
3 | Source: crates/ra_ide_api/tests/test/main.rs | ||
4 | |||
5 | [ | ||
6 | Diagnostic { | ||
7 | message: "unresolved module", | ||
8 | range: [4; 7), | ||
9 | fix: Some( | ||
10 | SourceChange { | ||
11 | label: "create module", | ||
12 | source_file_edits: [], | ||
13 | file_system_edits: [ | ||
14 | CreateFile { | ||
15 | source_root: SourceRootId( | ||
16 | 0 | ||
17 | ), | ||
18 | path: "foo.rs" | ||
19 | } | ||
20 | ], | ||
21 | cursor_position: None | ||
22 | } | ||
23 | ), | ||
24 | severity: Error | ||
25 | } | ||
26 | ] | ||