Update file structure tests

This commit is contained in:
Aleksey Kladov 2020-07-01 17:59:44 +02:00
parent 14bf5bb7ee
commit 53e3a7aeb4

View File

@ -173,12 +173,19 @@ fn structure_node(node: &SyntaxNode) -> Option<StructureNode> {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use expect::{expect, Expect};
use super::*; use super::*;
use insta::assert_debug_snapshot;
fn check(ra_fixture: &str, expect: Expect) {
let file = SourceFile::parse(ra_fixture).ok().unwrap();
let structure = file_structure(&file);
expect.assert_debug_eq(&structure)
}
#[test] #[test]
fn test_file_structure() { fn test_file_structure() {
let file = SourceFile::parse( check(
r#" r#"
struct Foo { struct Foo {
x: i32 x: i32
@ -223,12 +230,7 @@ fn obsolete() {}
#[deprecated(note = "for awhile")] #[deprecated(note = "for awhile")]
fn very_obsolete() {} fn very_obsolete() {}
"#, "#,
) expect![[r#"
.ok()
.unwrap();
let structure = file_structure(&file);
assert_debug_snapshot!(structure,
@r###"
[ [
StructureNode { StructureNode {
parent: None, parent: None,
@ -432,7 +434,7 @@ fn very_obsolete() {}
deprecated: true, deprecated: true,
}, },
] ]
"### "#]],
); );
} }
} }