simplify some tests

This commit is contained in:
Aleksey Kladov 2019-10-10 14:51:35 +03:00
parent ce0d4a3b1d
commit 5140283277

View File

@ -80,18 +80,15 @@ fn module_resolution_works_for_non_standard_filenames() {
#[test] #[test]
fn module_resolution_works_for_raw_modules() { fn module_resolution_works_for_raw_modules() {
let map = def_map_with_crate_graph( let map = def_map(
" "
//- /library.rs //- /lib.rs
mod r#async; mod r#async;
use self::r#async::Bar; use self::r#async::Bar;
//- /async.rs //- /async.rs
pub struct Bar; pub struct Bar;
", ",
crate_graph! {
"library": ("/library.rs", []),
},
); );
assert_snapshot!(map, @r###" assert_snapshot!(map, @r###"
@ -106,9 +103,9 @@ fn module_resolution_works_for_raw_modules() {
#[test] #[test]
fn module_resolution_decl_path() { fn module_resolution_decl_path() {
let map = def_map_with_crate_graph( let map = def_map(
r###" r###"
//- /library.rs //- /lib.rs
#[path = "bar/baz/foo.rs"] #[path = "bar/baz/foo.rs"]
mod foo; mod foo;
use self::foo::Bar; use self::foo::Bar;
@ -116,9 +113,6 @@ fn module_resolution_decl_path() {
//- /bar/baz/foo.rs //- /bar/baz/foo.rs
pub struct Bar; pub struct Bar;
"###, "###,
crate_graph! {
"library": ("/library.rs", []),
},
); );
assert_snapshot!(map, @r###" assert_snapshot!(map, @r###"
@ -133,7 +127,7 @@ fn module_resolution_decl_path() {
#[test] #[test]
fn module_resolution_module_with_path_in_mod_rs() { fn module_resolution_module_with_path_in_mod_rs() {
let map = def_map_with_crate_graph( let map = def_map(
r###" r###"
//- /main.rs //- /main.rs
mod foo; mod foo;
@ -147,9 +141,6 @@ fn module_resolution_module_with_path_in_mod_rs() {
//- /foo/baz.rs //- /foo/baz.rs
pub struct Baz; pub struct Baz;
"###, "###,
crate_graph! {
"main": ("/main.rs", []),
},
); );
assert_snapshot!(map, @r###" assert_snapshot!(map, @r###"
@ -167,7 +158,7 @@ fn module_resolution_module_with_path_in_mod_rs() {
#[test] #[test]
fn module_resolution_module_with_path_non_crate_root() { fn module_resolution_module_with_path_non_crate_root() {
let map = def_map_with_crate_graph( let map = def_map(
r###" r###"
//- /main.rs //- /main.rs
mod foo; mod foo;
@ -181,9 +172,6 @@ fn module_resolution_module_with_path_non_crate_root() {
//- /baz.rs //- /baz.rs
pub struct Baz; pub struct Baz;
"###, "###,
crate_graph! {
"main": ("/main.rs", []),
},
); );
assert_snapshot!(map, @r###" assert_snapshot!(map, @r###"
@ -201,7 +189,7 @@ fn module_resolution_module_with_path_non_crate_root() {
#[test] #[test]
fn module_resolution_module_decl_path_super() { fn module_resolution_module_decl_path_super() {
let map = def_map_with_crate_graph( let map = def_map(
r###" r###"
//- /main.rs //- /main.rs
#[path = "bar/baz/module.rs"] #[path = "bar/baz/module.rs"]
@ -211,9 +199,6 @@ fn module_resolution_module_decl_path_super() {
//- /bar/baz/module.rs //- /bar/baz/module.rs
use super::Baz; use super::Baz;
"###, "###,
crate_graph! {
"main": ("/main.rs", []),
},
); );
assert_snapshot!(map, @r###" assert_snapshot!(map, @r###"
@ -228,7 +213,7 @@ fn module_resolution_module_decl_path_super() {
#[test] #[test]
fn module_resolution_explicit_path_mod_rs() { fn module_resolution_explicit_path_mod_rs() {
let map = def_map_with_crate_graph( let map = def_map(
r###" r###"
//- /main.rs //- /main.rs
#[path = "module/mod.rs"] #[path = "module/mod.rs"]
@ -237,9 +222,6 @@ fn module_resolution_explicit_path_mod_rs() {
//- /module/mod.rs //- /module/mod.rs
pub struct Baz; pub struct Baz;
"###, "###,
crate_graph! {
"main": ("/main.rs", []),
},
); );
assert_snapshot!(map, @r###" assert_snapshot!(map, @r###"
@ -253,7 +235,7 @@ fn module_resolution_explicit_path_mod_rs() {
#[test] #[test]
fn module_resolution_relative_path() { fn module_resolution_relative_path() {
let map = def_map_with_crate_graph( let map = def_map(
r###" r###"
//- /main.rs //- /main.rs
mod foo; mod foo;
@ -265,9 +247,6 @@ fn module_resolution_relative_path() {
//- /sub.rs //- /sub.rs
pub struct Baz; pub struct Baz;
"###, "###,
crate_graph! {
"main": ("/main.rs", []),
},
); );
assert_snapshot!(map, @r###" assert_snapshot!(map, @r###"
@ -284,7 +263,7 @@ fn module_resolution_relative_path() {
#[test] #[test]
fn module_resolution_relative_path_2() { fn module_resolution_relative_path_2() {
let map = def_map_with_crate_graph( let map = def_map(
r###" r###"
//- /main.rs //- /main.rs
mod foo; mod foo;
@ -296,9 +275,6 @@ fn module_resolution_relative_path_2() {
//- /sub.rs //- /sub.rs
pub struct Baz; pub struct Baz;
"###, "###,
crate_graph! {
"main": ("/main.rs", []),
},
); );
assert_snapshot!(map, @r###" assert_snapshot!(map, @r###"
@ -315,7 +291,7 @@ fn module_resolution_relative_path_2() {
#[test] #[test]
fn module_resolution_explicit_path_mod_rs_2() { fn module_resolution_explicit_path_mod_rs_2() {
let map = def_map_with_crate_graph( let map = def_map(
r###" r###"
//- /main.rs //- /main.rs
#[path = "module/bar/mod.rs"] #[path = "module/bar/mod.rs"]
@ -324,9 +300,6 @@ fn module_resolution_explicit_path_mod_rs_2() {
//- /module/bar/mod.rs //- /module/bar/mod.rs
pub struct Baz; pub struct Baz;
"###, "###,
crate_graph! {
"main": ("/main.rs", []),
},
); );
assert_snapshot!(map, @r###" assert_snapshot!(map, @r###"
@ -340,7 +313,7 @@ fn module_resolution_explicit_path_mod_rs_2() {
#[test] #[test]
fn module_resolution_explicit_path_mod_rs_with_win_separator() { fn module_resolution_explicit_path_mod_rs_with_win_separator() {
let map = def_map_with_crate_graph( let map = def_map(
r###" r###"
//- /main.rs //- /main.rs
#[path = "module\bar\mod.rs"] #[path = "module\bar\mod.rs"]
@ -349,9 +322,6 @@ fn module_resolution_explicit_path_mod_rs_with_win_separator() {
//- /module/bar/mod.rs //- /module/bar/mod.rs
pub struct Baz; pub struct Baz;
"###, "###,
crate_graph! {
"main": ("/main.rs", []),
},
); );
assert_snapshot!(map, @r###" assert_snapshot!(map, @r###"
@ -365,7 +335,7 @@ fn module_resolution_explicit_path_mod_rs_with_win_separator() {
#[test] #[test]
fn module_resolution_decl_inside_inline_module_with_path_attribute() { fn module_resolution_decl_inside_inline_module_with_path_attribute() {
let map = def_map_with_crate_graph( let map = def_map(
r###" r###"
//- /main.rs //- /main.rs
#[path = "models"] #[path = "models"]
@ -376,9 +346,6 @@ fn module_resolution_decl_inside_inline_module_with_path_attribute() {
//- /models/bar.rs //- /models/bar.rs
pub struct Baz; pub struct Baz;
"###, "###,
crate_graph! {
"main": ("/main.rs", []),
},
); );
assert_snapshot!(map, @r###" assert_snapshot!(map, @r###"
@ -395,7 +362,7 @@ fn module_resolution_decl_inside_inline_module_with_path_attribute() {
#[test] #[test]
fn module_resolution_decl_inside_inline_module() { fn module_resolution_decl_inside_inline_module() {
let map = def_map_with_crate_graph( let map = def_map(
r###" r###"
//- /main.rs //- /main.rs
mod foo { mod foo {
@ -405,9 +372,6 @@ fn module_resolution_decl_inside_inline_module() {
//- /foo/bar.rs //- /foo/bar.rs
pub struct Baz; pub struct Baz;
"###, "###,
crate_graph! {
"main": ("/main.rs", []),
},
); );
assert_snapshot!(map, @r###" assert_snapshot!(map, @r###"
@ -424,7 +388,7 @@ fn module_resolution_decl_inside_inline_module() {
#[test] #[test]
fn module_resolution_decl_inside_inline_module_2_with_path_attribute() { fn module_resolution_decl_inside_inline_module_2_with_path_attribute() {
let map = def_map_with_crate_graph( let map = def_map(
r###" r###"
//- /main.rs //- /main.rs
#[path = "models/db"] #[path = "models/db"]
@ -435,9 +399,6 @@ fn module_resolution_decl_inside_inline_module_2_with_path_attribute() {
//- /models/db/bar.rs //- /models/db/bar.rs
pub struct Baz; pub struct Baz;
"###, "###,
crate_graph! {
"main": ("/main.rs", []),
},
); );
assert_snapshot!(map, @r###" assert_snapshot!(map, @r###"
@ -454,7 +415,7 @@ fn module_resolution_decl_inside_inline_module_2_with_path_attribute() {
#[test] #[test]
fn module_resolution_decl_inside_inline_module_3() { fn module_resolution_decl_inside_inline_module_3() {
let map = def_map_with_crate_graph( let map = def_map(
r###" r###"
//- /main.rs //- /main.rs
#[path = "models/db"] #[path = "models/db"]
@ -466,9 +427,6 @@ fn module_resolution_decl_inside_inline_module_3() {
//- /models/db/users.rs //- /models/db/users.rs
pub struct Baz; pub struct Baz;
"###, "###,
crate_graph! {
"main": ("/main.rs", []),
},
); );
assert_snapshot!(map, @r###" assert_snapshot!(map, @r###"
@ -485,7 +443,7 @@ fn module_resolution_decl_inside_inline_module_3() {
#[test] #[test]
fn module_resolution_decl_inside_inline_module_empty_path() { fn module_resolution_decl_inside_inline_module_empty_path() {
let map = def_map_with_crate_graph( let map = def_map(
r###" r###"
//- /main.rs //- /main.rs
#[path = ""] #[path = ""]
@ -497,9 +455,6 @@ fn module_resolution_decl_inside_inline_module_empty_path() {
//- /users.rs //- /users.rs
pub struct Baz; pub struct Baz;
"###, "###,
crate_graph! {
"main": ("/main.rs", []),
},
); );
assert_snapshot!(map, @r###" assert_snapshot!(map, @r###"
@ -516,7 +471,7 @@ fn module_resolution_decl_inside_inline_module_empty_path() {
#[test] #[test]
fn module_resolution_decl_empty_path() { fn module_resolution_decl_empty_path() {
let map = def_map_with_crate_graph( let map = def_map(
r###" r###"
//- /main.rs //- /main.rs
#[path = ""] // Should try to read `/` (a directory) #[path = ""] // Should try to read `/` (a directory)
@ -525,9 +480,6 @@ fn module_resolution_decl_empty_path() {
//- /foo.rs //- /foo.rs
pub struct Baz; pub struct Baz;
"###, "###,
crate_graph! {
"main": ("/main.rs", []),
},
); );
assert_snapshot!(map, @r###" assert_snapshot!(map, @r###"
@ -537,7 +489,7 @@ fn module_resolution_decl_empty_path() {
#[test] #[test]
fn module_resolution_decl_inside_inline_module_relative_path() { fn module_resolution_decl_inside_inline_module_relative_path() {
let map = def_map_with_crate_graph( let map = def_map(
r###" r###"
//- /main.rs //- /main.rs
#[path = "./models"] #[path = "./models"]
@ -548,9 +500,6 @@ fn module_resolution_decl_inside_inline_module_relative_path() {
//- /models/bar.rs //- /models/bar.rs
pub struct Baz; pub struct Baz;
"###, "###,
crate_graph! {
"main": ("/main.rs", []),
},
); );
assert_snapshot!(map, @r###" assert_snapshot!(map, @r###"
@ -567,7 +516,7 @@ fn module_resolution_decl_inside_inline_module_relative_path() {
#[test] #[test]
fn module_resolution_decl_inside_inline_module_in_crate_root() { fn module_resolution_decl_inside_inline_module_in_crate_root() {
let map = def_map_with_crate_graph( let map = def_map(
r###" r###"
//- /main.rs //- /main.rs
mod foo { mod foo {
@ -579,9 +528,6 @@ fn module_resolution_decl_inside_inline_module_in_crate_root() {
//- /foo/baz.rs //- /foo/baz.rs
pub struct Baz; pub struct Baz;
"###, "###,
crate_graph! {
"main": ("/main.rs", []),
},
); );
assert_snapshot!(map, @r###" assert_snapshot!(map, @r###"
@ -599,7 +545,7 @@ fn module_resolution_decl_inside_inline_module_in_crate_root() {
#[test] #[test]
fn module_resolution_decl_inside_inline_module_in_mod_rs() { fn module_resolution_decl_inside_inline_module_in_mod_rs() {
let map = def_map_with_crate_graph( let map = def_map(
r###" r###"
//- /main.rs //- /main.rs
mod foo; mod foo;
@ -614,9 +560,6 @@ fn module_resolution_decl_inside_inline_module_in_mod_rs() {
//- /foo/bar/qwe.rs //- /foo/bar/qwe.rs
pub struct Baz; pub struct Baz;
"###, "###,
crate_graph! {
"main": ("/main.rs", []),
},
); );
assert_snapshot!(map, @r###" assert_snapshot!(map, @r###"
@ -637,7 +580,7 @@ fn module_resolution_decl_inside_inline_module_in_mod_rs() {
#[test] #[test]
fn module_resolution_decl_inside_inline_module_in_non_crate_root() { fn module_resolution_decl_inside_inline_module_in_non_crate_root() {
let map = def_map_with_crate_graph( let map = def_map(
r###" r###"
//- /main.rs //- /main.rs
mod foo; mod foo;
@ -652,9 +595,6 @@ fn module_resolution_decl_inside_inline_module_in_non_crate_root() {
//- /foo/bar/qwe.rs //- /foo/bar/qwe.rs
pub struct Baz; pub struct Baz;
"###, "###,
crate_graph! {
"main": ("/main.rs", []),
},
); );
assert_snapshot!(map, @r###" assert_snapshot!(map, @r###"
@ -675,7 +615,7 @@ fn module_resolution_decl_inside_inline_module_in_non_crate_root() {
#[test] #[test]
fn module_resolution_decl_inside_inline_module_in_non_crate_root_2() { fn module_resolution_decl_inside_inline_module_in_non_crate_root_2() {
let map = def_map_with_crate_graph( let map = def_map(
r###" r###"
//- /main.rs //- /main.rs
mod foo; mod foo;
@ -690,9 +630,6 @@ fn module_resolution_decl_inside_inline_module_in_non_crate_root_2() {
//- /bar/baz.rs //- /bar/baz.rs
pub struct Baz; pub struct Baz;
"###, "###,
crate_graph! {
"main": ("/main.rs", []),
},
); );
assert_snapshot!(map, @r###" assert_snapshot!(map, @r###"
@ -732,7 +669,7 @@ fn unresolved_module_diagnostics() {
#[test] #[test]
fn module_resolution_decl_inside_module_in_non_crate_root_2() { fn module_resolution_decl_inside_module_in_non_crate_root_2() {
let map = def_map_with_crate_graph( let map = def_map(
r###" r###"
//- /main.rs //- /main.rs
#[path="module/m2.rs"] #[path="module/m2.rs"]
@ -744,9 +681,6 @@ fn module_resolution_decl_inside_module_in_non_crate_root_2() {
//- /module/submod.rs //- /module/submod.rs
pub struct Baz; pub struct Baz;
"###, "###,
crate_graph! {
"main": ("/main.rs", []),
},
); );
assert_snapshot!(map, @r###" assert_snapshot!(map, @r###"